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
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()
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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python cookies vj78 2 1,818 Apr-07-2021, 09:38 AM
Last Post: Naheed
  Problem with logging in on website - python w/ requests GoldeNx 6 2,017 Sep-25-2020, 10:52 AM
Last Post: snippsat
  How to perform a successful login(signin) through Requests in Python Kalet 1 1,377 Apr-24-2020, 01:44 AM
Last Post: Larz60+
  Flask, Posgresql - Multiple requests are not working bmaganti 5 1,395 Feb-20-2020, 03:02 PM
Last Post: bmaganti
  Scraping problems with Python requests. gtlhbkkj 1 943 Jan-22-2020, 11:00 AM
Last Post: gtlhbkkj
  requests problem in python script "content type" abdlwafitahiri 4 1,632 Dec-29-2019, 02:29 PM
Last Post: abdlwafitahiri
  error when inserting list statement from python to MySQL ADBYITMS 0 861 Nov-10-2019, 10:44 AM
  Catch all cookies from any website Chuky 8 5,437 Aug-20-2019, 04:24 PM
Last Post: snippsat
  python scraping all cookies halberdd 1 3,180 Feb-26-2019, 12:10 PM
Last Post: halberdd
  Flask: Cookies for Saving User Input ? jomonetta 2 2,198 Nov-03-2018, 10:47 AM
Last Post: j.crater

Forum Jump:

User Panel Messages

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