在perl中通过WWW::Mechanize登录不了网站
试了好久,也换了好多个参数了,但总登录不了...
$mech->success 的返回结果是1,但$mech->content 中总是有“密码输入错误”这样的提示。可那用户名和密码肯定是正确的啊,打开浏览器能正常登录。
测试代码:
#!/usr/bin/perluse strict;use WWW::Mechanize;my $loginUrl = 'http://passport.115.com/?ac=login&tpl=pc';my $mech = WWW::Mechanize->new();$mech->agent_alias('Windows IE 6');$mech->get($loginUrl);$mech->submit_form( form_id => 'loginForm', fields => { 'login%5Baccount%5D' => 'okabc123', 'login%5Bpasswd%5D' => 'abc123ha', 'goto' => 'http://115.com', },);print "isSuccess: ".$mech->success."\n".$mech->content."\n\n";
use constant UA => 'Opera/9.80 (X11; Linux i686; U; en) Presto/2.6.30 Version/10.60';my $mech=WWW::Mechanize->new(agent=>UA);