我需要curl登录网页并保存cookie ID供以后使用。
我尝试过各种各样的事情,比如
curl -k -c cookies.txt --data "txtUser=admin&txtPassword=password&cmdLogin=Login"https://192.168.1.1/login.html
但我无法让它发挥作用。看起来没有提交数据。
页面代码如下所示
<form id="loginForm">
<table style="margin:auto;width:1%">
<tbody>
<tr>
<td class="labelCell">User</td>
<td><input tabindex="1" id="txtUser" name="txtUser" type="text" /></td>
</tr>
<tr>
<td class="labelCell">Password</td>
<td><input tabindex="2" id="txtPassword" name="txtPassword" type="password" /></td>
</tr>
<tr>
<td colspan="2" style="text-align:center;padding-top:30px">
<input tabindex="3" name="cmdLogin" value="Login" type="submit" />
</td>
</tr>
</tbody>
</table>
</form>
我做错了什么?
编辑:
来自网页的Javascript请求
<script type="text/javascript">
var msgDiv;getStNavList();$(function(){msgDiv=$("#msgDiv");$("form").bind("submit",function(a){a.preventDefault();$.ajax({type:"POST",url:cgiScriptUrl,data:{user:$("#txtUser").val(),password:$("#txtPassword").val()},dataType:"text",async:false,success:function(b){if(b=="loggedin"){msgDiv.removeClass().addClass(successDivClass).html("Login successful").slideDown("slow");setTimeout("redirect()",1500)}else{msgDiv.removeClass().addClass(errorDivClass).html("Login failed").slideDown("slow");setTimeout("msgDiv.slideUp('slow')",2000)}}})});$("#txtUser").focus()});function redirect(){fullUrl=parent.document.URL;var a=fullUrl.indexOf("?")+1;if(a>0){window.location=fullUrl.substring(a,fullUrl.length)}else{window.location="general_status.html"}}function pollerror(a){if(a==undefined){a="Polling error"}$("#msgDiv").removeClass().addClass(errorDivClass).html(a).show()};</script>