wget不设置cookies

wget不设置cookies,cookies,session-cookies,wget,Cookies,Session Cookies,Wget,有人能告诉我为什么我的命令不起作用吗 这是我的表格: <form id="query" method="POST" action="https://weblogin.mycompany.com/" enctype="application/x-www-form-urlencoded" autocomplete="off"> <table border="0" align="center"> <tr> <td class="fieldname">Us

有人能告诉我为什么我的命令不起作用吗

这是我的表格:

<form id="query" method="POST" action="https://weblogin.mycompany.com/"
enctype="application/x-www-form-urlencoded" autocomplete="off">
<table border="0" align="center">
<tr>
<td class="fieldname">Username:</td>
<td><input type="text" name="user" size="20" value="" class="inputfield" /> </td>
</tr>
<tr>
<td class="fieldname">Password:</td>
<td><input type="password" name="pass" class="inputfield" /></td>
</tr>
<tr>
<td class="fieldname"></td>
<td><input type="submit" value="Log in &raquo;" /></td>
</tr>
</table>
<div id='notifyuser'></div>
</form>
以及http响应:

% wget --keep-session-cookies --save-cookies /tmp/wget03_cookies.txt --post-data 'user=my_id&pass=my_passwd' **https://weblogin.mycompany.com/**
 --2013-07-03 09:52:06--  https://weblogin.mycompany.com/
 Resolving weblogin.mycompany.com... 1.1.1.1
 Connecting to weblogin.mycompany.com|1.1.1.1|:443... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 4477 (4.4K) [text/html]
 Saving to: `index.html.10'

 100%[===========================================================================>] 4,477       --.-K/s   in 0s

 2013-07-03 09:52:06 (36.8 MB/s) - `index.html.10' saved [4477/4477]
我做错了什么


我可能会在以下线程中找到解决方案:

解决方案如下:

#!/bin/sh

# get the login page to get the hidden field data
wget -a log.txt -O loginpage.html http://foobar/default.aspx
hiddendata=`grep value < loginpage.html | grep foobarhidden | tr '=' ' ' | awk '{print $9}' | sed s/\"//g`
rm loginpage.html

# login into the page and save the cookies
postData=user=fakeuser'&'pw=password'&'foobarhidden=${hiddendata}
wget -a log.txt -O /dev/null --post-data ${postData} --keep-session-cookies --save-cookies cookies.txt http://foobar/default.aspx

# get the page your after
wget -a log.txt -O results.html --load-cookies cookies.txt http://foobar/lister.aspx?id=42
rm cookies.txt
#/垃圾箱/垃圾箱
#获取登录页面以获取隐藏字段数据
wget-a log.txt-O loginpage.htmlhttp://foobar/default.aspx
hiddendata=`grep value
我不明白的是-- 生成hiddendata时,我应该使用什么来替换“foobarhidden”

我相信下面的部分会给我答案,但我不知道该怎么做:

% grep value < loginpage.html | grep hidden
3:109:<input type=hidden name=pubcookie_g_req value="b25lPWFsb2hhLmFrYW1haS5jb20mdHdvPWFsb2hhJnRocmVlPTEmZm91cj1hNWEmZml2ZT1HRVQmc2l4PWFsb2hhLmFrYW1haS5jb20mc2V2ZW49THc9PSZlaWdodD0mYWthX2ZyYWc9Jmhvc3RuYW1lPWFsb2hhLmFrYW1haS5jb20mbmluZT0xJmZpbGU9JnJlZmVyZXI9KG51bGwpJnNlc3NfcmU9MCZwcmVfc2Vzc190b2s9NjMzMzQ0OTI3JmZsYWc9MA==">
4:110:<input type=hidden name=post_stuff value="">
5:111:<input type=hidden name=relay_url value="https://weblogin.mycompany.com/PubCookie.reply">
%grep值

谢谢!!

在你的问题中,你说你正在连接到
https://...
但在您的日志中是
http://...
-也许这就是问题所在?请确保您使用的是
https://...
在命令行上。

从服务器返回的HTTP响应中有什么内容?可能返回了错误?顺便说一句,我的wget's的版本是1.12。谢谢,@RichieHindle我将在“应答”区域发布回复,因为它太长了,无法放在这里。再次感谢。感谢您指出,@RichieHindle!我用https重试了它,结果是一样的。同样,消息将发布在应答区域。此外,“weblogin.mycompany.com”页面有很多Java脚本代码。这会导致wget停止工作吗?再次感谢!@CharlieYen:您应该将新信息编辑到问题中,而不是将其作为答案发布。谢谢您告诉我,@RichieHindle。对于这个论坛来说,这还是一种新信息。非常抱歉,没有遵守规则。我将删除回答区域中的新信息并更新原始帖子。再次感谢。@CharlieYen:文件
index.html.10
中有什么-可能是错误消息?要回答您的问题,请使用@RichieHindle。文件index.html.10是实际的登录页面,其中有一条错误消息:您的会话已过期。请重新登录。谢谢。
% grep value < loginpage.html | grep hidden
3:109:<input type=hidden name=pubcookie_g_req value="b25lPWFsb2hhLmFrYW1haS5jb20mdHdvPWFsb2hhJnRocmVlPTEmZm91cj1hNWEmZml2ZT1HRVQmc2l4PWFsb2hhLmFrYW1haS5jb20mc2V2ZW49THc9PSZlaWdodD0mYWthX2ZyYWc9Jmhvc3RuYW1lPWFsb2hhLmFrYW1haS5jb20mbmluZT0xJmZpbGU9JnJlZmVyZXI9KG51bGwpJnNlc3NfcmU9MCZwcmVfc2Vzc190b2s9NjMzMzQ0OTI3JmZsYWc9MA==">
4:110:<input type=hidden name=post_stuff value="">
5:111:<input type=hidden name=relay_url value="https://weblogin.mycompany.com/PubCookie.reply">