Python Forum
Inserting multiple cookies using python requests - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Inserting multiple cookies using python requests (/thread-12271.html)



Inserting multiple cookies using python requests - freshtomatoes - Aug-16-2018

I'm getting some cookies via selenium webdriver, d.get_cookies()
they are in dict format

I'm loaded them in selenium, and they work just fine.
Now i'm trying to load them with requests module...
i do requests.utls.cookiejar_from_dict(cookiedict)
then session.cookies.update(cj) for each cookie i've jarred^

i've seen session.cookies before i do session.get()
and it looks fine, they're in there
i even look at session.request.headers
and the cookies have been added there

but when i get the RESPONSE object.text from session.get()
basically the page is in a 'non cookie' state

s = requests.Session()
#load a page with selen, click stuff
#generate cookies, drink a coffee
selencookies = webdriver.get_cookies()
webdriver.quit() 
f = req.utils.cookiejar_from_dict
			for ck in selencookies:
				for k in ck:
					ck[k] = str(ck[k])
				s.cookies.update( f(ck) )
print s.cookies
a = s.get('this_url')
#parse a.text
print a.request.headers