cookies自动化再加

import requests
from http.cookiejar import LWPCookieJar
s = requests.Session()
headers = {   
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36'
}
#设置保存cookies得文件地址
s.cookies = LWPCookieJar(filename="test.txt")
#设置headers
s.headers.update(headers)
Response = s.post(url)
# 保存cookie
s.cookies.save()
# 加载cookie
s.cookies.load()
print(Response.text)

 

你可能感兴趣的:(cookies自动化再加)