寻求论坛Logoner解决方案 如何用Perl模拟登陆到西祠胡同
不知道西祠表单格式是什么 我看了一下返回页面的html 发现是接受了Username和Password 2个字符串
可是我在Perl里面尝试着这样
use HTTP::Request::Common qw(POST GET);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla 1.503 Windows XP");
my $url = "http://user.xici.net/user/logon.asp";
my $req = POST $url,[UserName => "Iostream",Password => "stdcpp"]; #假设我已经注册过一个Iostream的用户
my $res = $ua->request($req);
print $res->content;
发现返回的总是
<head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a HREF="/">here</a>.</body>
求教谢谢!~~~~是不是我url传入的有问题?
#############################################################
# Create a user agent object
use HTTP::Cookies;
use LWP;
use LWP::UserAgent;
use LWP::Authen::Basic;
$ua = LWP::UserAgent->new();
my $cookie = HTTP::Cookies->new();
$ua->cookie_jar($cookie);
$ua->agent("Mozilla/4.0 ");
$ua->credentials(UserName => "Iostream",Password => "stdcpp); //假设有这个用户可以从IE正常登陆
my $res = $ua->get('/user/hello.asp');
# Check the outcome of the response
print $res->content;
当我改成这样后,发现返回的总是登陆错误的页面~~~~