使用curl将数据发布到表单?

时间:2015-01-04 18:45:42

标签: forms curl

我有一个这样的表格:

<form method="post" enctype="multipart-form-data" name="my_form" action="http://www.sms-online.web.id/kirim" >

<input class="field text small" type="text" maxlength="20" name="Phonenumbers" />
<br />
<textarea rows="5" cols="20" onKeyPress=check_length(this.form); onKeyDown=check_length(this.form); name=Text ></textarea>
<br />
<input id="saveForm" class="btTxt" type="submit" value="KIRIM" name="TOMBOL" />
</form>

我们说该表单位于http://myurl.com/form如何发布到该表单,然后点击提交按钮?我的文件应该是什么样的?应该看起来像这样:

Phonenumbers=08111111
Text=SMScontent

我已经尝试了这个但是没有工作:

curl --data "Phonenumbers=0811111&text=testing&TOMBOL=KIRIM" http://myurl.com/form

我尝试了 @sputnick 建议,但收到了以下错误:

<!DOCTYPE html>
<html style="height:100%">
<head><title> 301 Moved Permanently
</title></head>
<body style="color: #444; margin:0;font: normal 14px/20px Arial, Helvetica, sans-serif; height:100%; background-color: #fff;">
<div style="height:auto; min-height:100%; ">     <div style="text-align: center; width:800px; margin-left: -400px; position:absolute; top: 30%; left:50%;">
        <h1 style="margin:0; font-size:150px; line-height:150px; font-weight:bold;">301</h1>
<h2 style="margin-top:20px;font-size: 30px;">Moved Permanently
</h2>
<p>The document has been permanently moved.</p>
</div></div><div style="color:#f0f0f0; font-size:12px;margin:auto;padding:0px 30px 0px 30px;position:relative;clear:both;height:100px;margin-top:-101px;background-color:#474747;border-top: 1px solid rgba(0,0,0,0.15);box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset;">
<br>Proudly powered by  <a style="color:#fff;" href="http://www.litespeedtech.com/error-page">LiteSpeed Web Server</a><p>Please be advised that LiteSpeed Technologies Inc. is not a web hosting company and, as such, has no control over content found on this site.</p></div></body></html>

3 个答案:

答案 0 :(得分:2)

您在Text字段中有一个拼写错误(需要大写),所以:

 curl -d "Phonenumbers=0811111&Text=testing&TOMBOL=KIRIM" http://myurl.com/form
 #                             ^

并且做这些事情,使用cookie和假的用户代理。检查

man curl

答案 1 :(得分:0)

使用-F标志POST多部分表格数据,如下所示:

curl -F "Phonenumbers=0811111&Text=testing&TOMBOL=KIRIM" http://myurl.com/form

答案 2 :(得分:0)

您可以使用

curl --data "dob=2018&press=OK" http://blog.eduguru.in/testapp.cgi