使用cURL登录POST表单

前端之家收集整理的这篇文章主要介绍了使用cURL登录POST表单前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用cURL(cURL的首次使用者)登录网站www.centralgreen.com.sg/login.PHP

我使用了Firefox的Tamper插件,我有4个POST输入:

login=mylogin
password=mypassword
Button_DoLogin.x=33
Button_DoLogin.y=6

我试着再次使用curl

curl.exe --data 'login=mylogin&password=mypassword&Button_DoLogin.x=33&Button_DoLogin.y=6' www.centralgreen.com.sg/login.PHP?ccsForm=Login

但是登录显然没有通过(此命令的输出是相同的形式,只填充了密码,并且出现错误消息“用户名”字段中的值是必需的.)

以下是我从Tamper获得的完整信息列表

Host centralgreen.com.sg
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept Language en-us,en;q=0.5
Accept Encoding gzip,deflate
Accept Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep Alive 115
Connection keep-alive
Referer http://centralgreen.com.sg/login.PHP
Cookie PHPSESSID=65fbxxxxxxx02694e3a72xxxxxxxx; Valley_ParkLogin=04E203A459FCxxxxxxxA2DCD9AAE5B9678G08C04F1952155E2482xxxxxxxxxxxxx

有什么我做错了吗?如何通过POST表单传递登录信息?

解决方法

尝试使用-F选项而不是–data.

http://curl.haxx.se/docs/manpage.html#-F

基本上,这会将内容类型标题更改为:

Content-Type: multipart/form-data

这可能会给你一个更好的结果.

原文链接:https://www.f2er.com/linux/394138.html

猜你在找的Linux相关文章