Home  >  Q&A  >  body text

Python使用已存储的Cookie请求页面

如图所示的Cookie,加载后一下再访问,
我使用了这样的代码

ck = cookielib.MozillaCookieJar()
ck.load(os.path.join('/home/kslr/xunlei-lixian-master', 'xun.cookie'))

报错:
does not look like a Netscape format cookies file

这个cookielib的使用我不是很清楚,找到的资料也很模糊,请帮我指点一下。

天蓬老师天蓬老师2718 days ago314

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 13:29:39

    There is the word LWP in

    , so you should use LWPCookieJar. Only those with Netscape should use MozillaCookieJar.

    reply
    0
  • PHPz

    PHPz2017-04-17 13:29:39

    The Session of Requests is quite good, you can give it a try.

    reply
    0
  • Cancelreply