2013-10-05 128 views
0

我正尝试编写一个快速应用程序以编程方式查看我的电费。为此,我需要能够以编程方式登录网站,然后才能继续进行其他任何操作。以编程方式登录到网站

我知道必须以某种方式使用卷曲。但是,我不确定如何利用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">&nbsp;</td> 
    <td align="left"> 
     <input name="login" type="submit" class="actionbutton" onClick="doLogin()" value="Log in"/> 
    </td> 
</tr> 

我知道我需要使用卷曲以某种方式能够登录,但我不知道如何。特别是因为登录逻辑是由'doLogin()'函数完成的,我不确定如何使用curl从终端调用该函数。这里是'doLogin()'函数的定义:

function doLogin() { 
    var wform = document.wizForm; 
    wform.type.value='LoginMenu'; 
} 

任何线索我怎么可以使用终端/卷曲登录到该页面?

回答

0

您错过了表单标签。 <form class="extform" action="/csg/inetSrv" method="post" name="wizForm">

最有可能你需要保存会话cookie,你登录后。

你需要做的是使用卷曲的表单数据发布到/ CSG/INETSRV。使用参数--cookie-jar <file>保存cookie。然后,您可以再次使用curl使用cookie文件发出请求,并且您已登录。

首先在浏览器中检查cookie以了解其使用方式可能更容易。然后,您可以在使用curl登录之前尝试使用curl与浏览器会话cookie进行测试。