卷曲功能可从选择框中选择选项并自动提交

发布于 2024-07-17 15:27:05 字数 896 浏览 7 评论 0原文

我是一个新手,每天都会尝试不同的事情,当我遇到困难时总是来这里。

我想使用curl和php编写一个脚本,该脚本转到此链接:http:// tools.cisco.com/WWCHhannels/LOCATR/openBasicSearch.do,然后浏览每个国家/地区的每个页面,捕获每个国家/地区每个合作伙伴的列表并将其保存到数据库中。

我不知道脚本如何从选择框中逐个选择国家并将页面重定向到国家/地区页面...这是要做的第一件事,一旦我们进入页面,模式匹配就会发挥作用,用于将名称和地址存储在我可以管理的数据库。

问题是在我们选择任何国家/地区 URL 之前::http://tools.cisco.com /WWChannels/LOCATR/BasicSearch.do 在我们选择国家/地区后,“印度”网址为:http://tools.cisco。 com/WWCHhannels/LOCATR/performBasicSearch.do ,没有提及任何选定的国家/地区。

我的想法是遍历 HTML 页面,并在数组中输入所有国家/地区,然后创建一个递归函数来调用具有特定国家/地区的页面,但为此我们需要在递归函数中为每个国家/地区提供不同的 URL,对吧?

请帮忙

i am a newbie and try different things everyday and always come here when i am stuck with something.

I want to write a script using curl and php that goes to this link :http://tools.cisco.com/WWChannels/LOCATR/openBasicSearch.do and then goes through each page for each country capturing a list of every partner in every country and saving it to database.

i have no ideas how script will select countries one by one from select box and redirect page to country page...which is the very first thing to do, once we are on the page pattern matching comes in play for storing name and address in database which i can manage.

Problem is before we select any country url is::http://tools.cisco.com/WWChannels/LOCATR/BasicSearch.do
and after we select country say 'india' url is:http://tools.cisco.com/WWChannels/LOCATR/performBasicSearch.do , there is no reference to any country selected.

The Idea that i had was to traverse the HTML page, and enter all countries in an array and then make a recursive function to call a page with specific country but for that we need something different in URL for each country in recursive function right?

Please help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若言繁花未落 2024-07-24 15:27:05

您的网址混乱,所以我看不到您正在谈论的确切页面,但是最有可能发生的是,当您更改国家/地区时,网站正在发出 POST< /code> 请求同一页面
使用像 country 这样的变量(尽管它可能是其他东西)以及您选择的国家/地区名称/国家/地区 ID 的值。 如果您在页面上查看源代码,您将能够看到正在传递的输入字段的名称。 完成此操作后,在发出 cURL 请求时,您可以设置 cuRL 选项CURLOPT_POSTFIELDS,内容如下:

要在 HTTP“POST”操作中发布的完整数据。 要发布文件,请在文件名前面添加 @ 并使用完整路径。 这可以作为 urlencoded 字符串(如“para1=val1¶2=val2&...”)传递,也可以作为以字段名称作为键、字段数据作为值的数组传递。

所以,记住这一点,你会做这样的事情:

$ch = curl_init('http://tools.cisco.com/WWChannels/LO...BasicSearch.do');
$ch = curl_setopt($ch, CURLOPT_POSTFIELDS, array('country' => 'India'));
$ch = curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($ch);
curl_close($ch);

不过,正如我所说,国家 => 印度的部分内容是对该领域可能会发生什么进行有根据的猜测。 您必须检查 HTML 才能找到答案。

Your url is messed up, so I can't see the exact page you are talking about, however what is most likely happening is that when you change the country the website is making a POST request to the same page
with a variable like country (although it may be something else) with the value of the country name/country id that you selected. If you View Source on the page you will be able to see the input field's name that is being passed on. Once you do that, while making your cURL request you can set the cuRL option of CURLOPT_POSTFIELDS, which reads like so:

The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. This can either be passed as a urlencoded string like 'para1=val1¶2=val2&...' or as an array with the field name as key and field data as value.

So, keeping that in mind you would do something like this:

$ch = curl_init('http://tools.cisco.com/WWChannels/LO...BasicSearch.do');
$ch = curl_setopt($ch, CURLOPT_POSTFIELDS, array('country' => 'India'));
$ch = curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($ch);
curl_close($ch);

As I said, though, the country => India part of it is an educated guess as to what the field might be passing. You have to inspect the HTML to find out for yourself.

ι不睡觉的鱼゛ 2024-07-24 15:27:05

对于自动化/抓取,我建议您使用虚拟浏览器,例如 SimpleBrowser。 它是 SimpleTest 的一部分,但您可以单独使用它。

For automation/scraping, I would recommend that you use a virtual browser, such as SimpleBrowser. It's part of SimpleTest, but you can use it on its own.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文