<pre name="code" class="cpp">use LWP::UserAgent; use HTTP::Cookies; use HTTP::Headers; use HTTP::Response; use Encode; use File::Temp qw/tempfile/; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $now = time(); $ua->agent("Mozilla/8.0"); my $cookie_jar = HTTP::Cookies->new( file => 'lwp_cookies.txt', autosave => 1, ignore_discard => 1 ); $ua->cookie_jar($cookie_jar); my $str=(rand(1)); #system ("del/f/s/q c:wj_qrcod*.jpg"); my $response = $ua->get("https://account.tongbanjie.com/generateImageCode?t=$now"); print "$str is $str "; if ($response->is_success) { $r = $response->decoded_content; # print $response->decoded_content; # or whatever } else { die $response->status_line; }; my ( $fh, $filename ) = tempfile( "tbj_qrcode_XXXX", SUFFIX => ".jpg", DIR => 'c:\' ); binmode $fh; print $fh $r; close $fh; my $name="登录二维码已经下载到本地"; my $str=encode("gbk",decode("utf8","$name")); print "$str [ $filename ] "; my $validCode = <STDIN>; print "$validCode is $validCode "; chomp $validCode; #https://account.tongbanjie.com/tongdun/generatetokenid?callback=jQuery172021522459380203696_1460130474156&_=1460130474380 my $url="https://account.tongbanjie.com/tongdun/generatetokenid?callback=jQuery172023142253021291004_$now&_=$now"; print "------------------------ "; print "$url is $url "; print "------------------------ "; my $response = $ua->get("$url"); if ($response->is_success) { $r = $response->decoded_content; print $response->decoded_content; # or whatever #jQuery172023142253021291004_1460127766498({"tongduntokenid":"c2e5ec6a65f94e7eac01fdb7e6c90156"}) if ($r =~ /jQuery.*{"tongduntokenid":"(.*?)"}/){$tongduntokenid=$1}; } print " "; print "$tongduntokenid is $tongduntokenid "; my $login_url = 'https://login.tongbanjie.com/web/submitlogin'; #$ua->default_header('Cookie'=>$cookie,'Referer'=>$login_url); my $res = $ua->post($login_url,{ 'MOBILE_DEVICE'=>'PC', 'password'=>xxxxxx, 'phone'=>'18072722237', 'pictureCode'=> $validCode, # 'redirectUrl' =>"https://www.tongbanjie.com/", 't'=>"$now", 'tongduntokenid'=>"$tongduntokenid" }); print "--------------- "; #my $content=$res->header('Location'); #my $content =~ s/\u([0-9a-fA-F]{4})/pack("U",,hex($1))/eg; print $res->header('Location'); print $res->status_line." "; print $res->as_string();#获取的是原始内容,包括响应头,响应正文 print $res->content(); #获取的是响应正文 print ".............................. "; my $response = $ua->get("https://trade.tongbanjie.com/trade/web/member/assets/myassets.html"); if ($response->is_success) { $r = $response->content; $str=encode("gbk",decode("utf8","$r")); print "$str is $str "; } my $response = $ua->get("https://www.tongbanjie.com/"); if ($response->is_success) { $r = $response->content; $str=encode("gbk",decode("utf8","$r")); print "$str is $str "; }