为什么 WWW::Mechanize 找不到正确的形式?
我正在使用 WWW::Mechanize 从网页检索表单:
#!/usr/bin/perl
use WWW::Mechanize;
my $mechanize = WWW::Mechanize->new();
$mechanize->proxy(['http', 'ftp'], 'http://proxy/');
$mechanize->get("http://www.temp.com/");
$mechanize->form_id('signin');
网站 HTML 的代码如下
<form action="https://www.temp.com/session" id="signin" method="post">
,但出现错误“
There is no form with ID "signin" at SiteScraper.pl
我该怎么办?”
I'm using WWW::Mechanize to retrieve a form from a webpage:
#!/usr/bin/perl
use WWW::Mechanize;
my $mechanize = WWW::Mechanize->new();
$mechanize->proxy(['http', 'ftp'], 'http://proxy/');
$mechanize->get("http://www.temp.com/");
$mechanize->form_id('signin');
The website HTML has code as follows
<form action="https://www.temp.com/session" id="signin" method="post">
but I get the error
There is no form with ID "signin" at SiteScraper.pl
What do I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在不确切知道可能是错误的情况下,您可能会尝试输出 WWW::Mechanize 能够在响应中找到的任何形式,方法是:
它应该输出所有形式及其各自的属性等。
仔细检查该形式是否在转储中,否则就会出现问题。然后检查表单的 ->{attr}->{id} 是否也是您所期望的。
您还可以尝试使用其他方式(例如按名称)选择表单,看看是否有帮助。
Without knowing exactly could be wrong, you might try to output whatever forms that WWW::Mechanize is able to find in the response by using:
It should output all the forms and their respective attributes etc.
Double check that the form is in the dump, otherwise something is wrong. Then check that the form's ->{attr}->{id} is what you expect as well.
You can also try to select the form using another way, e.g. by name, and see if that helps.