Answer the question
In order to leave comments, you need to log in
Where do cookies go?
Good day
When I look at the headers from the browser and find SetCookie in the server responses, which are not clear where they go
. I don’t find similar cookies in the browser’s cookie database, approx.
Set-Cookie: remember_user_token=blablabla--blabla; domain=.site.com; path=/;expires=Fri, 10-Feb-2017 10:04:58 GMT; HttpOnly
Set-Cookie: _site_session=blablabla--blabla; domain=site.com; path=/; HttpOnly
import requests
from bs4 import BeautifulSoup
url = "http://site.com"
heads = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0)Gecko/20100101 Firefox/51.0', 'Host':'site.com'}
s = requests.Session()
response = s.get(url, headers =heads)
print(response.headers.values)
#{'User-Agent': 'python-requests/2.12.4', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'}
s = requests.Session()
s.headers = heads
response = s.get(url, headers = s.headers)
print(response.headers.values)
#{'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0)Gecko/20100101 Firefox/51.0', 'Host': 'site.com'}
Answer the question
In order to leave comments, you need to log in
Because this is what it
should be:response = s.get(url, headers =heads)
heads = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0)Gecko/20100101 Firefox/51.0', 'Host':'site.com'}
s = requests.Session()
response = s.get(url, headers =heads)
print(response.headers.values)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question