Putting a `Cookie` in a `CookieJar`

前端 未结 10 1458
谎友^
谎友^ 2020-11-30 01:45

I\'m using the new Python Requests library to make http requests. I obtain a cookie from the server as text. How do I turn that into a CookieJar with the cookie

10条回答
  •  执笔经年
    2020-11-30 02:37

    Well cookielib.LWPCookieJar has load and save methods on it. Look at the format and see if it matches the native cookie format, you may well be able to load your cookie straight into a cookie jar using StringIO. Alternatively, if requests is using urllib2 under the hood couldn't you add a cookie handler to the default opener?

提交回复
热议问题