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 command SELECT * 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 to requests
so that the cookies become usable.
The request
's docs say you need to pass in a dict, ie cookies={'cookies':'are_working'}
but then some of the keys name
s overwrite each other, since a few of the name
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
?
For Google Chrome go to View > Developer > Developer Tools or CMD + ALT + I on Mac or F12 on Windows. Now open the Application tab and check the cookies for each domain. Usually the cookies have names that resemble the name of the service they are being used by.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With