python 登录保持

import requests
url =' http://127.0.0.1:5000/login',
ur2 =''
json ={'username': '15669910105', 'password': 'a123456'}
#cookies
res = requests.post(url=url ,json=json )         #登录
res = requests.get(url=ur2 ,cookies=res.cookies) #第二个接口

#Session 继承
s = requests.Session()
res = s.post(url=url ,json=json ) #登录
res = s.get(url=ur2)              #第二个接口

猜你喜欢

转载自www.cnblogs.com/shuzf/p/11736382.html