python将response中的cookies加入到header

url = “http://abad.com”
header = {
"user-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3423.2 Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded",
"Referer": "http://ABDAF.com/login",
'Cookie': 'id5AA=c5/nn1vC8o4vZul8i2zJAg==; Hm_lvt_b4a22b2e0b326c2da73c447b951236d6746=1539760959; xxzl_deviceid=F 3hTrG /V/iuVTvmXAxCandrfhokre4OxgMOfI7Tgxtvi1aO/IsvAfVCg7v1KEn;"
data = {"aaa":"bbb"}
res = request.post(url,data,headers=header)
header['cookie'] =";".join([header['Cookie'],";".join('='.join(i) for i in res.cookies.items())])

url =“http://abad.com/123.html”
res = request.get(url)

转载于:https://www.cnblogs.com/VseYoung/p/9916009.html

你可能感兴趣的:(python将response中的cookies加入到header)