#2
wp2319572023-05-12 10:53
回复 楼主 Z89
|
程序代码:
import requests,json
s = requests.session()
a = s.get("https://www.baidu.com")
cookies = requests.utils.dict_from_cookiejar(s.cookies)
with open(".\cook.txt", "w") as fp:
json.dump(cookies, fp)
第二次 读取使用cookie会错报 TypeError: string indices must be integers
程序代码:
import requests,json
f = open('./cook.txt', 'r',encoding='UTF-8')
cookies=f.read()
f.close()
s = requests.session()
a = s.get("https://www.baidu.com",cookies=cookies)