将数据发布到表单cURL

时间:2013-09-04 00:56:50

标签: linux curl

我正在尝试使用curl将数据发布到表单并将其保存在文件中,这里是我要发布数据的表单,可以在此处访问网页form_webpage

<label for='Fldname'>Name</label></td><td>:</td><td><input type='text' name='name' id='Fldname'/>
    <label for='Fldemail'>Email</label></td><td>:</td><td><input type='text' name='email' id='Fldemail'/>
    <input type='password' name='x' id='Fldpwd'/>
    <input type='password' name='cpwd' id='Fldcpwd'/>
    <input type='radio' value='m' name='gender' id='Fldgendm'/> 
   <label for='Fldgendm'>Male</label> <input type='radio' value='f' name='gender' id='Fldgendf' />
   <label for='Fldgendf'>Female</label>
   <input type='checkbox' value='e' name='lang[]' id='Fldlange'/> Eng <input type='checkbox' value='t' name='lang[]'      id='Fldlangt'/> Tel <input type='checkbox' value='h' name='lang[]' id='Fldlangh' disabled />
    <select name='coun' multiple >
<option value=''>Choose Country</option>
<option value='91'>INDIA</option>
<option value='001'>USA</option>
<option value='002'>United Kingdom</option>
</select>

我做了相当多的研究,每次我想发布到表格,它都会返回同一页面 我用了

curl --data 'name=stirumer&email=123@gmail.com&x=test&cpwd=test&gender=m&lang[]=e&coun=91' "www.cs.odu.edu/~stirumer/index.html" -o "3.html"

curl -Gd 'name=stirumer&email=123@gmail.com&x=test&cpwd=test&gen
der=m&lang[]=e&coun=91' "www.cs.odu.edu/~stirumer/index.html" -o "3.html"

curl -X POST -F 'name=stirumer&email=123@gmail.com&x=test&cpwd=test&gender=m&lang[]=e&coun=91' www.cs.odu.edu/~stirumer/index.html -o "2.html"

curl -F 'name=stirumer&email=123@gmail.com&x=test&cpwd=test&gend
er=m&lang[]=e&coun=91' www.cs.odu.edu/~stirumer/index.html -o "1.html"

curl -X POST --data "name=stirumer&email=123@gmail.com&x=test&cpwd=test&gender=m&lang[]=e&coun=91" www.cs.odu.edu/~stirumer/index.html 

所有人都返回同一页面。!!

预期产出 Should this be the output if it is correct?

需要帮助的人!

2 个答案:

答案 0 :(得分:3)

这是解决这个问题的一种方法,我发现这对于类似的活动非常有用。

在Firefox中安装FirebugFirecurl。启动Firebug,然后浏览到相关页面并提交表单。然后在Firebug的Net Panel中,看看他的Firecurl输出。它为您提供表单提交的CURL命令行,您可以将其剪切并粘贴到shell中并执行。了解任何POST需要做的事情的好方法。

答案 1 :(得分:1)

您期望发生什么?我去了你的网页并测试了它,我得到了,我期望发生的事情。当您手动转到该网页并填写信息并单击“提交”时,只需返回空白页面即可。如果你用curl做同样的想法,那么你也会回到空白页面。我首先要确保您的页面在浏览器中工作,就像您认为的那样。

当您使用curl时,就像您填写了所有表单字段并单击了提交。它不会只是将数据放入表单字段,然后只返回该页面。

相关问题