Answer the question
In order to leave comments, you need to log in
How to pass cookies to a website using python3?
For normal work on the site through python in my personal accounts, I want to transfer cookies to the site.
I get it like this:
import http.cookiejar, urllib.request
import http.client, urllib.parse, requests, json
import time
import re, os
cj = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
params = urllib.parse.urlencode({'identity' : 'LOGIN',
'password' : 'PAROL4ik'
})
r = opener.open('http://site.../auth/login', params.encode('utf-8'))
for i in cj:
cok=i.value
print(cok)
>>> url = 'http://httpbin.org/cookies'
>>> cookies = dict(cookies_are='working')
>>> r = requests.get(url, cookies=cookies)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question