Python requests模块保存COOKIE更新

COOKIE = {
    "Cookie": '__cfduid=def03b19933fd994bff59a377ec396ee01580718716; Hm_lvt_14b14198b6e26157b7eba06b390ab763=1580801448; Hm_lvt_526caf4e20c21f06a4e9209712d6a20e=1580718619,1580801941; PHPSESSID=nm4svjacnulrhd956kh01u7cm4; zkhanecookieclassrecord=%2C53%2C; zkhanmlusername=%C0%CF%D3%CD%CC%F5PPT; zkhanmluserid=392644; zkhanmlgroupid=3; zkhanmlrnd=8dC1g0BPourLp7KlrI4e; zkhanmlauth=d16f57ce86525448e243c325e5285374; Hm_lpvt_526caf4e20c21f06a4e9209712d6a20e=1580868118',
    'Connection': 'close'}
S = requests.session()
S.headers.update(COOKIE)
stream = S.get(getdownpath, stream=True)
if stream.status_code == 403:
    print('获取下载图片返回403')
    return False
if '</script>' in stream.text:
    print('需要登陆下载,请更新COOKIE')
    return False
if stream.cookies.get_dict():
    S.cookies.update(stream.cookies.get_dict())


支付宝扫码打赏 微信扫码打赏

如果本文对你有帮助,欢迎打赏本站

喜欢 ()or分享
    匿名评论
  • 评论
人参与,条评论