- 论坛徽章:
- 0
|
自己搞的,不知为什么似乎没提交上去表单。- #!perl -w
- use strict;
- use 5.010;
- use Encode;
- use LWP::UserAgent;
- use HTTP::Cookies;
- use LWP::ConnCache;
- open TST, ">:encoding(gb2312)" , "tst.htm";
- my %form;
- $form{"usename"} = "wotest";
- $form{"password"} = "pswt";
- $form{"cookietime"} = "3153600";
- $form{"t"} = "";
- $form{"formhash"} ="";
- $form{"loginsubmit"} ="";
- $form{"referer"} ="";
- my $ua = LWP::UserAgent->new(keep_alive => 1);
- $ua->agent('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; MathPlayer 2.20; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3)');
- $ua->timeout(10);
- HTTP::Cookies->new(file=>'cookies.dat',autosave=>1);
- $ua->default_header( 'Accept-Language' => 'en-US', 'Accept-Charset' => 'utf-8');
- my ($html,);
- my $response = $ua->get('http://emuch.net/bbs/logging.php?action=login' );
- if ($response->is_success) {
- $html = $response->decoded_content;
- }
- $form{"t"} = $1 if $html =~ m{logging.php\?action=login&t=(\d+)}i;
- $form{"formhash"} = $1 if $html =~ m{name="formhash" value="([^"]+)"}i;
- $form{"loginsubmit"} = "会员登录";#"%BB%E1%D4%B1%B5%C7%C2%BC";
- say join "\n" ,map {join " ", $_, $form{$_}} keys %form;
- $response = $ua->post("http://emuch.net/bbs/logging.php?action=login&t=" . $form{"t"} , \%form);
- if ($response->is_success) {
- $html = $response->decoded_content;
- }
- say TST $html;
复制代码 |
|