perl 加载cookie 请求
来源:互联网 发布:mac 终端登录mysql 编辑:程序博客网 时间:2024/05/22 07:42
use Net::SMTP;use LWP::UserAgent;use HTTP::Cookies;use HTTP::Headers;use HTTP::Response;use Encode;use Switch;use File::Temp qw/tempfile/;use HTTP::Date qw(time2iso str2time time2iso time2isoz);my $CurrTime = time2iso(time());my $ua = LWP::UserAgent->new;$ua->timeout(10);$ua->env_proxy;my $now = time();$ua->agent('Mozilla/5.0');my $cookie_jar = HTTP::Cookies->new( file => 'lwp_cookies.txt', autosave => 1, ignore_discard => 1);$ua->cookie_jar($cookie_jar);if ( $cookie_jar){$cookie_jar->load( $cookie_jar );my $now = time();my $url="https://www.awfae.com/web/auth?method=%2Fwze%2Ftransfer%2Fcash%2Fin&amount=0.1&tradePassword=79e8fe923f031f46221a9283d0c9263a&_=$now";my $response = $ua->get("$url");if ($response->is_success) {#print $response->content; $r = $response->content; $str=encode("gbk",decode("utf8","$r"));print "\$str is $str\n";}if ($str =~/用户未登录/){##https://www.awfae.com/validcode/generate-validcode.do?0.36789621218278434my $response = $ua->get("https://www.awfae.com/validcode/generate-validcode.do");if ($response->is_success) { $r = $response->decoded_content; # print $response->decoded_content; # or whatever}else { die $response->status_line;};my ( $fh, $filename ) = tempfile( "wj_qrcode_XXXX", SUFFIX => ".jpg", DIR => 'c:\\' );binmode $fh;print $fh $r;close $fh;print "登录二维码已经下载到本地 [ $filename ] \n";##打开图片system("start $filename ");my $validCode = <STDIN>;chomp $validCode ; my $login_url = 'https://www.awfae.com/business/dispatch_post.do'; my $res = $ua->post($login_url,{ 'action'=>'doLogin', 'userName'=>'18072722237', 'followId'=>'', 'userPass'=>'79e8fe923f031f46221a9283d0c9263a', 'validCode'=> "$validCode" }); print "---------------\n";my $head =$res->header('Location');;print $res->header('Location');print "\n";my $response = $ua->get("$head");if ($response->is_success) { #print $response->content; $r = $response->content; $str=encode("gbk",decode("utf8","$r"));print "\$str == $str\n";}my $now = time();my $url="https://www.awfae.com/web/auth?method=%2Fwze%2Ftransfer%2Fcash%2Fin&amount=0.1&tradePassword=79e8fe923f031f46221a9283d0c9263a&_=$now";my $response = $ua->get("$url");if ($response->is_success) {#print $response->content; $r = $response->content; $str=encode("gbk",decode("utf8","$r"));print "\$str is $str\n";}}}##http://www.awfae.com/login.html?info=\u767b\u5f55\u5931\u8d25\u003a\u7528\u6237\##http://www.awfae.com/login.html?info=登录失败:用户\##http://www.awfae.com/account/myAccount.html?subPage=/account/dashBoard.html&uuid=20150925104158452da9e0c7979d4438&# 响应头:# 原始头信息# Connection# close# Content-Language# zh-CN# Content-Length# 0# Date# Fri, 01 Sep 2017 00:57:34 GMT# Location# https://www.awfae.com/account/myAccount.html?subPage=/account/dashBoard.html&uuid=20150925104158452da9e0c7979d4438# &# Server# Apache-Coyote/1.1# Set-Cookie# rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Thu, 31-Aug-2017 00:57:34 GMT# X-Frame-Options# SAMEORIGIN
阅读全文
0 0
- perl 加载cookie 请求
- Android 加载需要携带cookie的图片请求
- cookie请求
- perl 获取cookie
- perl 使用cookie
- perl 读取cookie
- perl load cookie方法
- Perl 发送http 请求。
- perl 自定义请求头
- perl 自定义请求头
- Perl 模拟DELETE 请求
- perl head 请求
- 保存请求cookie 读取cookie
- 解决Android Http请求处理Response Cookie时区加载过慢问题
- Cookie请求头字段
- iOS 请求带cookie
- AFNetWorking 请求携带cookie
- Jmeter带cookie请求
- MVN的常用命令介绍
- 46. Permutations
- js将两个数的除数保留两位小数
- 总结骏汇项目的一些js逻辑问题(一)之数据提交
- [Objective-C]利用枚举将NSString拆分句子出来
- perl 加载cookie 请求
- The variance for this alert is **MB which is 20% of the **MB average (**MB is the limit)
- LeetCode之Longest Substring Without Repeating Characters
- STM32移植LWIP网线热插入网络不通的解决办法
- A
- docker
- traceView文件如何分析
- FTP在项目文档管理中的应用
- cookie 内的sessionid