0

I have a cookie file generated with this shell command:

curl -L --cookie-jar cookies --cookie cookies 'https://test.test/'

I already did the log in, so using this command I have already access to the web page. Now I would like to use this cookie file within a python script. My script needs this cookie to identify the session, but I could not make it work.

Using the following generates a new cookie, which does not include the session I created before. How can I include the existing cookie file within a request.get() in python?

# Making a get request
response = requests.get('https://test.test/')

# printing request cookies
print(response.cookies)
panador
  • 25
  • 6
  • `requests.get('https://test.test/', cookies=cookies)` – dallonsi Mar 16 '21 at 13:36
  • That does not work since my cookie file is saved locally as a text file that I want to refrence here. I get the error: name 'cookies' is not defined – panador Mar 16 '21 at 22:37
  • ok so why don't you save the cookie in a json file on your system and load it in a variable names `cookies` ? – dallonsi Mar 17 '21 at 08:15

0 Answers0