2016-02-29 100 views
-4

我目前做一個bash腳本,需要我登錄一個網站,下載主頁(女巫包括一些HTML表格),並在將表格導出到文件後!網站登錄形式從終端

對我來說,困難的部分是處理網站登錄。
我嘗試與捲曲(捲曲 - 用戶用戶:傳遞域),但沒有任何工作,因爲我所料。

請讓我知道,如果你有任何想法如何使其工作或如何以不同的方式做到這一點。

預先感謝您

網站源代​​碼

<?xml version="1.0" encoding="utf-8" standalone="no" ?> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
 
\t "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"> 
 

 
<head> 
 
    <meta name="robots" content="noindex, nofollow" /> 
 
    <meta name="Googlebot" content="noindex, nofollow" /> 
 
    <meta http-equiv="Content-Language" content="en-gb" /> 
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
 
    <title> 
 
    Starbase 
 
    </title> 
 
    <script language="javascript" type="text/javascript"> 
 
    //<![CDATA[ 
 

 
    function showLoading() { 
 
     document.getElementById('lyrLoading').style.display = 'inline'; 
 
     } 
 
     //]]> 
 
    </script> 
 
</head> 
 

 
<body link="#000080" vlink="#000080" alink="#000080"> 
 
    <table border="0" width="100%" height="100%"> 
 
    <tr> 
 
     <td> 
 
     <div align="center"> 
 
      <p align="center"> 
 
      <img border="0" src="images/imgLogoSmall.gif" /> 
 
      </p> 
 
      <p align="center"> 
 
      <font face="Arial" color="#FF0000" size="2">You need to enter both an e-mail address and password.</font> 
 
      </p> 
 
      <table border="0" width="250"> 
 
      <tr> 
 
       <td> 
 
       <form onsubmit="javascript:window.setTimeout('showLoading();', 1);" method="post" action="/index.asp" name="loginform" id="loginform"> 
 
        <input type="hidden" name="process" value="1" /> 
 
        <p align="center"> 
 
        <font face="Arial"><img border="0" src="images/imgUser.gif" /><br /> 
 
\t \t \t \t \t \t \t \t \t \t \t <input name="username" size="25" style="text-align: center; font-family: Arial; font-size: 14;" /></font> 
 
        </p> 
 
        <p align="center"> 
 
        <font face="Arial"><img border="0" src="images/imgPassword.gif" /><br /> 
 
\t \t \t \t \t \t \t \t \t \t \t <input type="password" name="password" size="25" style="text-align: center; font-family: Arial; font-size: 14;" /></font> 
 
        </p> 
 
        <p align="center"> 
 
        <font face="Arial"><input type="image" src="http://picpaste.com/extpics/btnLogIn-UM9GoIxr.gif" name="B1" /></font> 
 
        </p> 
 
       </form> 
 
       <table border="0" width="100%"> 
 
        <tr> 
 
        <td align="center"> 
 
         <a href="passwordMgmt.asp?action=1" rel="nofollow"><font face="Arial,helvetica" size="1">Forgot password</font></a> 
 
        </td> 
 
        <td align="center"> 
 
         <p align="center"> 
 
         <a href="passwordMgmt.asp?action=2" rel="nofollow"><font face="Arial,helvetica" size="1">Change password</font></a> 
 
         </p> 
 
        </td> 
 
        </tr> 
 
       </table> 
 
       </td> 
 
      </tr> 
 
      </table> 
 
     </div> 
 
     </td> 
 
    </tr> 
 
    </table> 
 
    <script type="text/javascript"> 
 
    //<![CDATA[ 
 
    document.loginform.username.focus(); 
 
    //]]> 
 
    </script> 
 
    <div style="display: none; z-index: 5; position: absolute; width: 500px; height: 260px; top: 50%; left: 50%; margin-top: -130px; margin-left: -250px;" id="lyrLoading"> 
 
    <div align="center"> 
 
     <table border="0" width="100%" height="100%"> 
 
     <tr> 
 
      <td> 
 
      <div align="center"> 
 
       <table border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF" style="border: 2px solid #A6CDF9" width="200" height="130"> 
 
       <tr> 
 
        <td> 
 
        <img border="0" src="images/imgLoading.gif" width="32" height="32" align="right" /> 
 
        </td> 
 
        <td> 
 
        <p align="left"> 
 
         <font face="arial,helvetica" size="2">Logging in...</font> 
 
        </p> 
 
        </td> 
 
       </tr> 
 
       </table> 
 
      </div> 
 
      </td> 
 
     </tr> 
 
     </table> 
 
    </div> 
 
    </div> 
 
</body> 
 

 
</html>

回答

1

貌似你試圖用基本身份驗證憑據登錄。

你的網頁在表格期待表單數據:

curl --data "param1=value1&param2=value2" http://example.com/ 

所以你的情況,你應該提供類似的東西:

curl --data "username=aUserName&password=thePassword" http://example.com/index.asp 

資源:

https://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request

+0

它沒有工作,我回到作爲一個無效的密碼HTML頁面的結果。你見過源代碼嗎? ?? –

+0

以及不是一個標準的形式發佈(我不知道很多關於形式或發佈請求) –

+0

嘗試添加隱藏的輸入字段到您的發佈請求數據它可能是某種必需的參數。在你發佈的html中,它聲明「process = 1」。 'curl --data「username = aUsername&password = thePassword&process = 1」http:// example.com/index.asp「 如果這樣做不起作用,那麼您將需要提供更多關於您實際網站的信息試圖從中請求這些數據。 – Keystone