我正在尝试写一个快速的应用程序来查看我的电费账单编程。为此,我需要能够以编程方式登录到网站,然后我才能继续其他任何事情。
我知道必须以某种方式使用curl。但是,我不确定如何利用curl通过终端登录网站。以下是网站:Seattle Utilitiy Bills Website
查看登录表单的对应源代码,如下所示:
<tr>
<td nowrap class="form-style-text">User ID:</td>
<td class="form-style-label"><input type="text" autocomplete="off" size="17" name="loginid" maxlength="32"></td>
</tr>
<script type="text/javascript">document.wizForm.loginid.focus()</script>
<tr>
<td class="form-style-text">Password:</td>
<td class="form-style-label"><input type="password" autocomplete="off" name="password" size="17" maxlength="16"></td>
</tr>
<tr>
<td class="form-style-text"> </td>
<td align="left">
<input name="login" type="submit" class="actionbutton" onClick="doLogin()" value="Log in"/>
</td>
</tr>我知道我需要以某种方式使用curl才能登录,但我不确定如何使用。特别是因为登录逻辑是由'doLogin()'函数完成的,而我不确定如何使用curl从终端调用该函数。下面是'doLogin()'函数的定义:
function doLogin() {
var wform = document.wizForm;
wform.type.value='LoginMenu';
}有什么线索可以让我使用终端/curl登录这个页面吗?
发布于 2013-10-05 17:11:40
您错过了表单标签。<form class="extform" action="/csg/inetSrv" method="post" name="wizForm">
最有可能的情况是,您需要在登录后保存会话cookie。
您需要做的是使用curl将表单数据发送到/csg/inetSrv。使用参数--cookie-jar <file>保存cookie。然后,您可以再次使用curl对cookie文件发出请求,并且您已登录。
首先在浏览器中检查cookie以了解它是如何使用的可能更容易。然后,在使用curl登录之前,可以尝试使用curl和浏览器的会话cookie进行测试。
https://stackoverflow.com/questions/19195791
复制相似问题