curl 的 post 请求...难道和 wget 和 python 的 requests 有什么不一样嘛!

2016-09-09 11:14:54 +08:00
 miaobug
import requests
data = {'username':'xxxxxxxxxx', 'password':'xxxxxxxxxx', 'iprange':'no'}
r = requests.post("https://xxx.edu.cn/cas/webLogin",data=data)

可以用

wget --post-data "username=xxxxxxxxxx&password=xxxxxxxxxx&iprange=no" https://xxx.edu.cn/cas/webLogin

也可以用

curl -X POST -D "username=xxxxxxxxxx&password=xxxxxxxxxx&iprange=no" https://xxx.edu.cn/cas/webLogin
curl -X POST -H "Content-Type:application/x-www-form-urlencoded" -D "username=xxxxxxxxxx&password=xxxxxxxxxx&iprange=no" https://xxx.edu.cn/cas/webLogin
curl -X POST -F "name=xxxxxxxx" -F passwd="xxx" -F ... https://xxx.edu.cn/cas/webLogin

这些格式怎么都不行... 请老司机指点!

3430 次点击
所在节点    问与答
4 条回复
xjp
2016-09-09 11:50:03 +08:00
估计是要 application/json
UnisandK
2016-09-09 12:02:40 +08:00
http://requestb.in/
都发个 post 过去比较一下就可以了
awanabe
2016-09-09 12:07:22 +08:00
data=json.dumps(data) 试试
awanabe
2016-09-09 12:08:05 +08:00
如果是 python2 而且参数有中文 data=json.dumps(data, ensure_ascii=False, indent=2),

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/305016

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX