WWW::Mechanize 和 Yellowpages.com
我正在尝试通过 Perl 模块 WWW::Mechanize 搜索 Yellowpages.com。
$mech->get( "http://www.yellowpages.com" );
$mech->form_name( "standard-searchform" );
$mech->field( "search-terms, "schneider" );
$mech->field( "search-location", "CA" );
$mech->submit();
我还尝试使用按钮值/类型 $mech->submit_form( ... ) ,但我始终收到以下消息:
Error POSTing http://www.yellowpages.com/real_deals: Internal Server Error at /usr/lib/cgi-bin/index.pl line 39
第 39 行是
$mech->submit();
Is yp.com 将 Mechanize 转发到该站点吗?我怎样才能避免这种情况?
I'm trying to search yellowpages.com via the Perl module WWW::Mechanize.
$mech->get( "http://www.yellowpages.com" );
$mech->form_name( "standard-searchform" );
$mech->field( "search-terms, "schneider" );
$mech->field( "search-location", "CA" );
$mech->submit();
I also tried $mech->submit_form( ... ) with the button value/type, but I get the following message all the time:
Error POSTing http://www.yellowpages.com/real_deals: Internal Server Error at /usr/lib/cgi-bin/index.pl line 39
Line 39 is
$mech->submit();
Is yp.com forwarding Mechanize to that site? How can I avoid that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先你在search-terms后面漏掉了一个
"
。查看黄页的源代码,没有名为“standard-searchform”的表单。该表单的id为“searchform-form”所以这个例子应该可以工作:编辑:
搜索词和搜索位置也是输入 ID,其中 WWW::Mechanize 的文档说:
这意味着您应该使用以下命令更改它们:search_terms 和 geo_location_terms。
First you've missed a
"
after search-terms. Looking at the source code of yellowpages, there is no form with name "standard-searchform". The form is with an id "searchform-form". So that example should work:EDIT:
also the search-terms and search-location are the input ids, where the documentation of the WWW::Mechanize says:
That means you should change them with: search_terms and geo_location_terms.