http 响应头之location
2016-08-03 20:35
302 查看
<pre name="code" class="html">jrhmpt01:/root# cat login_yylc.pl use LWP::UserAgent; use HTTP::Date qw(time2iso str2time time2iso time2isoz); use Net::Ping; use Socket; use Net::SMTP; use LWP; use LWP::Simple; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Headers; use HTTP::Response; use Encode; use URI::Escape; use URI::URL; use Data::Dumper; my $ua = LWP::UserAgent->new; $ua->timeout(5); $ua->env_proxy; $ua->agent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0"); my $cookie_jar = HTTP::Cookies->new( file=>'lwp_cookies.txt', autosave=>1, ignore_discard=>1); $ua->cookie_jar($cookie_jar); #$var='https://licai.yingyinglicai.com/index.htm'; #<input type="hidden" id="token" name="token" value="3E79AB8CF9603A03DF74DDD6154A8BAD"/> my $var='https://licai.yingyinglicai.com/user/login.htm'; my $response = $ua->get($var); $var= $response->decoded_content; ##<input type="hidden" id="token" name="token" value="7C84D7FD0889D23EAA8D266979552D2D"/> if ($var =~/.*token"\s+value="(.*?)"/.*/) {print "\$1 is $1\n"; $token=$1; }; my $login_url = 'https://licai.yingyinglicai.com/user/loginByPwd.do'; my $res = $ua->post($login_url,{ 'cell'=>18072xx2237, 'password'=>80xx5, 'token'=>$token }, 'Host'=>'licai.yingyinglicai.com', 'User-Agent'=>'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0' ); my $homepage; print "header-----------------\n"; print $res->header('Location'); print "header-----------------\n"; $1 is DC341A499F42389A5EA4841042C7C04F header----------------- http://licai.yingyinglicai.com/index.htm header----------------- $h->header( $field ) $h->header( $field => $value ) $h->header( $f1 => $v1, $f2 => $v2, ... ) 获取或者设置 一个或者多个header字段的值,header 字段名($field)不是大小写敏感的。 为了使perl 用户生活更简单 需要避免引号在=>操作符前,你可以使用'_' 作为一个替代'-' 在header names header()方法接收多个键值对,这意味着你可以更新多个fields在一个领域 Examples: $header->header(MIME_Version => '1.0', User_Agent => 'My-Web-Client/0.01'); $header->header(Accept => "text/html, text/plain, image/*"); $header->header(Accept => [qw(text/html text/plain image/*)]); @accepts = $header->header('Accept'); # get multiple values $accepts = $header->header('Accept'); # get values as a single string 响应头: Connection keep-alive Content-Language zh-CN Content-Length 0 Date Wed, 03 Aug 2016 12:22:20 GMT Location http://licai.yingyinglicai.com/index.htm Server nginx Set-Cookie YYLCSJSESSIONID=f9d49ab5-acc4-4518-a6ab-ec73a6ae39eb; Domain=yingyinglicai.com; Expires=Wed, 03-Aug-2016 12:52:20 GMT; Path=/ print $res->header('Server'); 返回nginx
相关文章推荐
- http 响应头之location
- http 响应头之location
- 登陆成功5s后倒计时跳转(http响应头refresh,location)
- Http 协议 请求 响应
- Angularjs 常用服务 $http $location $anchorScroll $cacheFactory $timeout $interval $sce
- ASP.NET中指定自定义HTTP响应标头
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance(xsi:schemaLocation详解)
- 关于获取java获取http响应头信息
- 使用 BizTalk Http Receive location
- HTTP请求报文和HTTP响应报文
- http学习笔记(模拟http请求和响应过程)
- Apache Sirona Java应用监视器,能够实时获得每个http/JDBC响应时间
- HTTP响应状态码
- 服务器响应HTTP的类型ContentType大全
- http响应Last-Modified和ETag以及Apache和Nginx中的配置
- 004_Http之response响应头-02定时刷新(定时重定向)
- 在HTTP响应标题中隐藏ASP.NET MVC的版本
- android获取URLConnection和HttpClient网络请求响应码
- HTTP请求报文和响应报文
- HTTP响应状态码 含义