Python Forum
Inserting multiple cookies using python requests
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inserting multiple cookies using python requests
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Saving/editing cookies? rhubarbpieguy 0 889 Dec-10-2022, 01:58 PM
Last Post: rhubarbpieguy
  POST requests - different requests return the same response Default_001 3 1,881 Mar-10-2022, 11:26 PM
Last Post: Default_001
  Python cookies vj78 2 3,050 Apr-07-2021, 09:38 AM
Last Post: Naheed
  Problem with logging in on website - python w/ requests GoldeNx 6 5,176 Sep-25-2020, 10:52 AM
Last Post: snippsat
  How to perform a successful login(signin) through Requests in Python Kalet 1 2,295 Apr-24-2020, 01:44 AM
Last Post: Larz60+
  Flask, Posgresql - Multiple requests are not working bmaganti 5 2,646 Feb-20-2020, 03:02 PM
Last Post: bmaganti
  Scraping problems with Python requests. gtlhbkkj 1 1,818 Jan-22-2020, 11:00 AM
Last Post: gtlhbkkj
  requests problem in python script "content type" abdlwafitahiri 4 3,099 Dec-29-2019, 02:29 PM
Last Post: abdlwafitahiri
  error when inserting list statement from python to MySQL ADBYITMS 0 1,532 Nov-10-2019, 10:44 AM
Last Post: ADBYITMS
  Catch all cookies from any website Chuky 8 10,109 Aug-20-2019, 04:24 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020