T
T
tincap2016-04-26 15:07:58
Python
tincap, 2016-04-26 15:07:58

How to save cookies to a file in Python?

url = 'https://ya.ru'
r = requests.get(url)

for item in r.cookies:
  print(item)

Here are the page cookies. Now I have to manually save cookies in a file and manually pull them out?
In PHP, all this is made simpler:
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2016-04-26
@dimonchik2013

well, it's easier in Python, use pycurl.io instead of requests or urllib

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question