卷曲功能可从选择框中选择选项并自动提交
我是一个新手,每天都会尝试不同的事情,当我遇到困难时总是来这里。
我想使用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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的网址混乱,所以我看不到您正在谈论的确切页面,但是最有可能发生的是,当您更改国家/地区时,网站正在发出
POST< /code> 请求同一页面
使用像
country
这样的变量(尽管它可能是其他东西)以及您选择的国家/地区名称/国家/地区 ID 的值。 如果您在页面上查看源代码,您将能够看到正在传递的输入字段的名称。 完成此操作后,在发出 cURL 请求时,您可以设置 cuRL 选项CURLOPT_POSTFIELDS
的 ,内容如下:所以,记住这一点,你会做这样的事情:
不过,正如我所说,国家 => 印度的部分内容是对该领域可能会发生什么进行有根据的猜测。 您必须检查 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 pagewith 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 ofCURLOPT_POSTFIELDS
, which reads like so:So, keeping that in mind you would do something like this:
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.
对于自动化/抓取,我建议您使用虚拟浏览器,例如 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.