1. 程式人生 > >python將response中的cookies加入到header

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://passport.58.com/login",
'Cookie': 'id58=c5/nn1vC8o4vZul8i2zJAg==; 58tj_uuid=4383532e-d2c9-4036-a3b1-bd7afb95ced9; als=0; city=bj; Hm_lvt_b4a22b2e0b326c2da73c447b956d6746=1539760959; myfeet_tooltip=end; xxzl_deviceid=F 3hTrG /V/iuVTvmXAxCandrfhokre4OxgMOfI7Tgxtvi1aO/IsvAfVCg7v1KEn; commontopbar_new_city_info=1|北京|bj; commontopbar_ipcity=bj|北京|0; bangtoptipclose=1; 28191176522503_opened_menu_id=-5-206-; showOrder=1; new_uv=4; utm_source=; spm=; init_refer=https://vip.58.com/?pts=1541484167976; new_session=0; ppStore_fingerprint=A60D45925324F20C5F01C574653CCDD64F238AFA14FC11C3_1541484276034'
}
data = {"aaa":"bbb"}
res = request.post(url,data,headers=header)
header['cookie'] = ';'.join([header['cookie'], ['='.join(i) for i in res.cookies.items()]])
url =“http://abad.com/123.html”
res = request.get(url)