我用python为我的程序做了一个小原型,在这个原型中我需要登录一个网站。为此,我做到了:
import requests as req
session = req.Session()
req.post("somesite.com", data={"procedure": "login", "username": "JohnSmith", "password": "hunter7"})后来,我所有的API调用都运行得很好。
然而,在rust (使用ureq)中,我似乎无法做到这一点。这是我的代码:
let agent = ureq::Agent::new();
agent.post("somesite.com")
.query("procedure", "login")
.query("username", "JohnSmith")
.query("password", "hunter7")
.call().unwrap();我已经检查过了,与python版本不同,在rust版本中没有任何会话cookie。
发布于 2021-10-25 15:44:54
正如@justinas所说,我需要使用Request::send_form而不是query。
https://stackoverflow.com/questions/69710638
复制相似问题