用Python保留cookies和会话不起作用

2024-10-02 00:40:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在Python中使用请求时保持登录状态。我尝试过使用会话和cookies,但是我总是遇到一个413无效会话错误。这是我的密码:

s = requests.Session()
url = "http://"+edge_server+":7780/xtvschedule/rest//UserManager/Login"
rsp = s.post(url, json = Body1, auth=("1002","0123"))
print (rsp.status_code)
cookie = rsp.cookies


url ="http://"+edge_server+":7780/xtvschedule/rest//ContentManager/BrowseRecordedAssets"
rsp = s.get(url,cookies=cookie)
print(rsp.status_code)
print(rsp.content)

谢谢你的帮助

以下是在soapui上正确运行的api和Cookie: 1


Tags: resthttpurl密码servercookie状态status

热门问题