加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl – 如何手动将cookie添加到WWW :: Mechanize已经存在的cook

发布时间:2020-12-15 23:21:41 所属栏目:大数据 来源:网络整理
导读:我有一个perl脚本,在获取页面后,我需要在已经存在cookie的已经存在的cookiejar中添加一个cookie.我该怎么做呢?我希望有一个 python机械化样式.set_cookie()函数 解决方法 一个 WWW::Mechanize对象是 LWP::UserAgent,它有一个cookie_jar属性,通常包含一个 HT
我有一个perl脚本,在获取页面后,我需要在已经存在cookie的已经存在的cookiejar中添加一个cookie.我该怎么做呢?我希望有一个 python机械化样式.set_cookie()函数

解决方法

一个 WWW::Mechanize对象是 LWP::UserAgent,它有一个cookie_jar属性,通常包含一个 HTTP::Cookies对象,它有一个set_cookie方法.

所以你要做的事情如下:

$mech->cookie_jar->set_cookie( $version,$key,$val,$path,$domain,$port,$path_spec,$secure,$maxage,$discard,%rest )

The set_cookie() method updates the state of the $cookie_jar. The $key,$port and $path arguments are strings. The $path_spec,$discard arguments are boolean values. The $maxage value is a number indicating number of seconds that this cookie will live. A value <= 0 will delete this cookie. %rest defines various other attributes like “Comment” and “CommentURL”.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读