Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl WWW::Mechanize和yellowpages.com_Perl_Module_Mechanize_Www Mechanize - Fatal编程技术网

Perl WWW::Mechanize和yellowpages.com

Perl WWW::Mechanize和yellowpages.com,perl,module,mechanize,www-mechanize,Perl,Module,Mechanize,Www Mechanize,我试图通过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(); 我还

我试图通过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();

yp.com是否将转发机械化到该站点?如何避免这种情况?

首先,您在搜索词之后遗漏了一个“”。查看yellowpages的源代码,没有名为“standard searchform”的表单。该表单的id为“searchform form”。因此,该示例应适用于:

my $mech = WWW::Mechanize->new;

$mech->get( "http://www.yellowpages.com" );
$mech->form_id( "searchform-form" );
$mech->field( "search-terms", "schneider" );
$mech->field( "search-location", "CA" );
$mech->submit();
编辑:

搜索词和搜索位置也是输入ID,其中WWW::Mechanize的文档说明:

给定字段的名称,将其值设置为指定的值


这意味着你应该用:search\u terms和geo\u location\u terms来更改它们。

谢谢,我在我的帖子中更正了它。我也尝试了searchform form,但得到了相同的错误。代码对你有用吗?这是表单的id,所以应该是form\u id而不是form\u Name谢谢你,我将其更改为form\u id,还将id更改为Name。Wor好了!我回到了第1版,因为这个问题在其他方面没有意义。(别担心,我们都会犯错误:)