5

In the amazing Python Requests lib, does it have the capability to automatically detect timeouts or cookie expiries? I'm logging into a page to retrieve some Json, and don't want to waste bandwidth by logging in each time:

s=requests.Session()
login_url='https://site/login'
payload = {'password': 'pw', 'email': 'email'}
loginr=s.post(login_url, data=payload)
url='https://site/json.json'
json_string = s.get(url)
the_data = json_string.json()

Or will I have to detect if s exists, then get the cookie dict, then check if the specific "logged in" cookie exists?

Thanks

Will

4

0 回答 0