1

I am trying to read and load a cookies.txt file saved on my local computer in Python.

But I keep getting the following error:

TypeError: a bytes-like object is required, not 'str'

My code looks as follow:

with open ("cookies.txt", "r") as text_file:
    yup = requests.utils.cookiejar_from_dict(pickle.load(text_file))
cookies = yup

What am I doing wrong or what am I missing here? I downloaded the cookies with the cookies.txt extension.

Solaiman
  • 298
  • 2
  • 7
  • 22
  • Possible duplicate of [Using cookies.txt file with Python Requests](https://stackoverflow.com/questions/14742899/using-cookies-txt-file-with-python-requests) – Nazim Kerimbekov Jun 16 '18 at 16:41

1 Answers1

1

try rb read-bytes

with open ("cookies.txt", "rb") as text_file:
    ...
Druta Ruslan
  • 7,171
  • 2
  • 28
  • 38