python session手动添加cookies键值并保持
import requests
ses = requests.session()
requests.utils.add_dict_to_cookiejar(ses.cookies,{"sessionid":"04r6wd81ew8egds5e8d16fe8g45s"})
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36'}
params = {
'id': '527111177076',
'_u': '61gre1jeb466',
}
response = ses.get('https://baidu.com', params=params, headers=headers)
prrint(response.text)
后面所有请求都会带上sessionid":"04r6wd81ew8egds5e8d16fe8g45s