Home > AI > Language > Python > requests >

get cookie

url = "https://www.apeuni.com/zh-CN/practice/essays/24"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'}

s = requests.Session()
response = s.get(url, headers=headers)
print(response.cookies) # RequestCookieJar

for c in response.cookies:
    print(c.domain)
    print(c.name)
    print(c.value)

Leave a Reply