How to save requests (python) cookies to a file?

前端 未结 10 1702
渐次进展
渐次进展 2020-11-30 17:35

How to use the library requests (in python) after a request

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
bot = requests.session         


        
10条回答
  •  爱一瞬间的悲伤
    2020-11-30 17:43

    dtheodor's answer got 95% there, except this:

    session = requests.session(cookies=cookies)
    

    For me this raises an exception saying session() does not takes arguments.

    I worked around it by taking the keys/values on the cookie.get_dict and adding them manually to the session using:

    session.cookies.set(cookies.keys()[n],cookies.values()[n])
    

提交回复
热议问题