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 File::Temp qw/tempfile/;
my $ua = LWP::UserAgent->new;
$ua->timeout(5);
$ua->env_proxy;
$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 $login_url = 'http://192.168.32.83/zabbix/index.php';
my $res = $ua->post($login_url,{
'autologin'=>'1',
'enter'=>'Sign in',
'name'=>'admin',
'password'=>'zabbix'
},
'User-Agent'=>'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0',
'Host'=>'192.168.32.83',
'Referer'=>'http://192.168.32.83/zabbix/'
); my $content = $res->content();
print $res->status_line . "\n";
print $res->as_string();
print $res->content(); open (LOG ,"<","/home/scan/lwp_cookies.txt");
while (<LOG>) {
chomp;
$sid=$1 if ($_ =~ /.*zbx_sessionid=(.*?);.*/)
}; print $sid."\n";; $cookie_jar->scan(sub {
my ($k,$v)=@_[1,2];
if ($k eq 'zbx_sessionid'){
$sid=$v;
};
});
print $sid."\n"; [root@dr-mysql01 ~]# perl zz.pl
302 Found
HTTP/1.1 302 Found
Connection: close
Date: Fri, 15 Jul 2016 02:04:10 GMT
Location: tr_status.php
Server: Apache/2.2.15 (CentOS)
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Client-Date: Fri, 15 Jul 2016 02:11:26 GMT
Client-Peer: 192.168.32.83:80
Client-Response-Num: 1
Set-Cookie: zbx_sessionid=e9365512c43faa607f76c9306f979cfc; expires=Mon, 15-Aug-2016 02:04:10 GMT
Set-Cookie: zbx_sessionid=99142dca7311038e6d335d32060b5ef3; expires=Mon, 15-Aug-2016 02:04:10 GMT
X-Powered-By: PHP/5.3.3 e9365512c43faa607f76c9306f979cfc
99142dca7311038e6d335d32060b5ef3
[root@dr-mysql01 ~]# cat lwp_cookies.txt
#LWP-Cookies-1.0
Set-Cookie3: zbx_sessionid=99142dca7311038e6d335d32060b5ef3; path="/zabbix"; domain=192.168.32.83; expires="2016-08-15 02:04:10Z"; version=0

perl 读取cookie的更多相关文章

  1. 用javascript设置和读取cookie的例子

    请看下面用javascript设置和读取cookie的简单例子,现在的问题是,如果要设置的是一个cookie集,比如在cookie1集中有uname,uid两组信息,应该如何写呢?cookie(&qu ...

  2. 运用JS设置cookie、读取cookie、删除cookie

    JavaScript是运行在客户端的脚本,因此一般是不能够设置Session的,因为Session是运行在服务器端的.而cookie是运行在客户端的,所以可以用JS来设置cookie. 假设有这样一种 ...

  3. JS设置cookie、读取cookie、删除cookie

    JS设置cookie.读取cookie.删除cookie       JS设置cookie,注意一定要path=/ ,根目录,不然其他目录可能查询不到..默认是本目录. document.cookie ...

  4. js设置和读取cookie

    /*path参数:表示cookie所在的目录,.net默认为/(根目录).在同一个服务器上有目录如下:/test/,/test/aa/,/test /bb/,现设一个cookie1的path为/tes ...

  5. 读取Cookie及Cookie所有属性操作方法

    读取Cookie及Cookie所有属性操作方法 2013-08-04 22:21:43|  分类: 技术 |  标签:cookie  |举报|字号 订阅   要把Cookie发送到客户端,Servle ...

  6. JavaScript 设置、读取Cookie

    1.设置Cookie //设置cookie function setCookie(cookieName, cookieValue, cookieExpires, cookiePath) { cooki ...

  7. Servlet课程0426(九)Servlet服务器端创建Cookie和客户端读取Cookie

    服务器端创建Cookie: Win7默认Cookie位置 C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Cookies Cookie ...

  8. servlet读取cookie问题

    String sessionid = request.getSession().getId(); // 取得当前的session id ckSessionid = new Cookie("s ...

  9. Java Web SSH框架总是无法写入无法读取Cookie

    不关乎技术,关乎一个小Tips: 默认情况下,IE和Chrome内核的浏览器会认为http://localhost为无效的域名,所以不会保存它的cookie,使用http://127.0.0.1访问程 ...

随机推荐

  1. Ownership qualifiers of Objective-C: In Details

    虽然这里讲的大部分知识以前都看过,但是时不时出现某些点让我如茅塞顿开: 以前经常会忘记一些细节,这篇文章可以更好的理解细节,巩固知识体系. Ownership qualifiers In Object ...

  2. Android外部存储 - 官方文档解读

    预备知识:External Storage Technical Information 摘要: "The WRITE_EXTERNAL_STORAGE permission must onl ...

  3. 剖析MFC六大关键技术(五六)--消息映射与命令传递

    说到消息,在MFC中,“最熟悉的神秘”可算是消息映射,那是我们刚开始接触MFC时就要面对的东西.有过SDK编程经验的朋友转到MFC编程的时候,一下子觉得什么都变了样.特别是窗口消息及对消息的处理跟以前 ...

  4. uva11178 Morley’s Theorem(求三角形的角三分线围成三角形的点)

    Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states that that the ...

  5. Drainage Ditches(最大流)

    Drainage Ditches Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64044   Accepted: 2471 ...

  6. 关于方法中的形参out

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  7. 判断圆和矩形是否相交C - Rectangle and Circle

    Description Given a rectangle and a circle in the coordinate system(two edges of the rectangle are p ...

  8. 素数环(C - 暴力求解)

    素数环(暴力)(紫书194页) Description   A ring is composed of n (even number) circles as shown in diagram. Put ...

  9. IP数据包结构

    Linux 网络编程——IP 数据报格式详解 http://www.linuxidc.com/Linux/2015-04/116149.htm

  10. [HDU 1016]--Prime Ring Problem(回溯)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1016 Prime Ring Problem Time Limit: 4000/2000 MS (Jav ...