我正在尝试使用wget
登录网站。表格看起来像这样。
<form name='frmLogin' action='Login' method='post'>
<table class='login'>
<tr>
<td class='label'>
<div class='alignRight'>Username: <span class='mandatory'>*</span></div>
</td>
<td class='field'>
<input type='text' name='txtUsername' size='10' maxlength='10' value='' onBlur="validatePassword(this, true)" onKeyPress="checkText(this, event)">
</td>
</tr>
<tr>
<td class='label'>
<div class='alignRight'>Password: <span class='mandatory'>*</span></div>
</td>
<td class='field'>
<input type='password' name='txtPassword' size='10' maxlength='10' value='' onBlur="validatePassword(this, true)" onKeyPress="checkText(this, event)">
</td>
</tr>
</table>
<div class='toolbar'>
<input type='button' class='button' name='btnSubmit' value='Login' onClick="javascript:formSubmit()" />
<input type='reset' class='button' name='btnReset' value='Clear' />
<input type='button' class='button' name='btnExit' value='Exit' onClick="javascript:navigateTo('index.jsp')" />
</div>
</form>
我使用以下命令登录并保存cookie并使用该cookie访问页面。但是当我使用那个cookie时,我的会话已经过期了。
wget --no-check-certificate --auth-no-challenge --keep-session-cookies --save-cookies cookie104.txt --header="Cookie: $cookie" --post-data="txtUsername=$name&txtPassword=$pass&btnSubmit=Login" ${site}login.jsp
wget --load-cookie cookie104.txt --no-check-certificate ${site}home.jsp
Cookie内容:
cat cookie104.txt
# HTTP cookie file.
# Generated by Wget on 2017-01-19 13:54:37.
# Edit at your own risk.
xyz02.com FALSE /dpl FALSE 0 JSESSIONID AA86E0BCE03A3D419953A928E590F184
从主页输出:
HTTP request sent, awaiting response... 302 Found
Location: login.jsp?msg=Your current session has expired. Please log in again. [following]
--2017-01-19 13:54:38-- https://xyz02.com/dpl/login.jsp?msg=Your%20current%20session%20has%20expired.%20Please%20log%20in%20again.
请告知我在这里缺少的是什么。我的目的是从主页面获取详细信息,并使用sendmail通过电子邮件发送。