perl lwp关闭ssl校验

use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Headers;
use HTTP::Response;
use Encode;
use File::Temp qw/tempfile/;
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, );;
$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://www.zjtest2.com/validcode/generate-validcode.do?$str");


print "\$str is $str\n";
if ($response->is_success) {
  $r = $response->decoded_content;   
# print $response->decoded_content;  # or whatever
}
else {
print $response->decoded_content;
 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 ;
print "\$validCode is $validCode\n";

#my $url="https://www.zjtest2.com/business/dispatch_post.do";

 my $login_url = 'https://www.zjtest2.com/business/dispatch_post.do';
                
 my $res = $ua->post($login_url,{
	                       'action'=>'doLogin',
                          'userName'=>'kevin',
						  'followId'=>'',
                          'userPass'=>'3d24b838770ee90773804e8599e549ff',
                          'validCode'=> "$validCode"
                                                });
			 print "---------------\n";

my $head =$res->header('Location');					
print $res->header('Location');	
print "\n";	

					
print $res->status_line."\n";
print $res->as_string();#获取的是原始内容,包括响应头,响应正文

my $content=$res->content();  
print $res->content();            #获取的是响应正文

my $spool = encode("gbk",decode("utf8","$content"));	
print "\$spool is $spool\n";
  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 is $str\n";

}else{ $r = $response->content;  
	print $response->content; };
	

	
my $url="https://www.zjtest2.com/business/dispatch_get.do?action=doDeposit";
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";

}else{ $r = $response->content;  
	print $response->content; };
	
	while(1==1){
	
##转入2级市场现金现金
##https://www.zjtest2.com/web/auth?method=%2Fwze%2Ftransfer%2Fcash%2Fin&amount=1&tradePassword=79e8fe923f031f46221a9283d0c9263a&_=1460426257542
##1460426541
my $now          = time();
my $url="https://www.zjtest2.com/web/auth?method=%2Fwze%2Ftransfer%2Fcash%2Fin&amount=2&tradePassword=3d24b838770ee90773804e8599e549ff&_=$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";

}else{ $r = $response->content;  
	print $response->content; };	
	
	
###转出到1级市场现金
##https://www.zjtest2.com/web/auth?method=%2Fwze%2Ftransfer%2Fcash%2Fin&amount=2&tradePassword=3d24b838770ee90773804e8599e549ff&_=1460441529452
###https://www.zjtest2.com/web/auth?method=%2Fwze%2Ftransfer%2Fcash%2Fout&amount=2&tradePassword=79e8fe923f031f46221a9283d0c9263a&_=$now

my $url="https://www.zjtest2.com/web/auth?method=%2Fwze%2Ftransfer%2Fcash%2Fout&amount=2&tradePassword=3d24b838770ee90773804e8599e549ff&_=$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";

}else{ $r = $response->content;  
	print $response->content; };	
	
	};

你可能感兴趣的:(perl lwp关闭ssl校验)