如何使用 WWW:Mechanize 登录 [英] How to use WWW:Mechanize to login
本文介绍了如何使用 WWW:Mechanize 登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想登录波斯博客服务.这是我的代码:
I want to login to a persian blogging service . This is my code:
#!/usr/bin/perl
use WWW::Mechanize;
$mech = WWW::Mechanize->new();
$url = "http://blogfa.com/Desktop/Login.aspx?t=1";
$mech->get($url);
$result = $mech->submit_form(
form_name => 'aspnetForm', #name of the form
#instead of form name you can specify
#form_number => 1
fields =>
{
'master$ContentPlaceHolder1$Uid' => 'my username', # name of the input field and value
'master$ContentPlaceHolder1$Password' => 'my password',
}
,'master$ContentPlaceHolder1$btnSubmit' => 'ورود به بخش مدیریت' #name of the submit button
);
$result->content();
if ($result =~ /میز کار/) {
print "Done\n"; }
else {
print "Failed!\n"; }
但它根本不起作用.有什么问题?
But it doesn't work at all. What is the problem?
推荐答案
问题是,WWW:Mechanize
不执行 javascript.由于您要登录的站点使用 javascript 进行登录,因此无法这样做.
The problem is, that WWW:Mechanize
does not execute javascript. Since the site you want to log in uses javascript for logging in, its not able to do that.
您可以使用WWW::Mechanize::Firefox
,它允许你执行javascript.
You could fix that problem by using WWW::Mechanize::Firefox
, which allows you to execute javascript.
这篇关于如何使用 WWW:Mechanize 登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文