I’m trying to log in to the http://www.steampowered.com website using the cookies I’ve got from my Chrome session.
Once I’ve grabbed all the
cookie
table’s data, using the commandSELECT * FROM cookie WHERE host_key LIKE '%steam%'
and the column names:PRAGMA table_info(cookie)
and sorted through all the data with a list comprehension, I don’t know how to pass it all torequests
so that the cookies become usable.The
request
‘s docs say you need to pass in a dict, iecookies={'cookies':'are_working'}
but then some of the keysname
s overwrite each other, since a few of thename
s are :Steam_Language
, though they’re different hosts.edit: Just found How to add cookie to existing cookielib CookieJar instance in Python? which might help me out, but I don’t know how to format the Chrome cookies for cookielib
My question is: How do I pass several different sites worth of cookies to
requests
?
Answer
I created a module to load cookies from Firefox.
Example usage with requests:
import requests
import browser_cookie
cj = browser_cookie.firefox()
r = requests.get(url, cookies=cj)
Attribution
Source : Link , Question Author : TankorSmash , Answer Author : Kodiologist