2

我使用 wget 以及 --post-data 和 --save-cookies 选项设法通过了网站的登录表单。

现在我尝试填写网页的一些字段,然后提交。问题是,网页上有一个“图灵”隐藏字段,每次都是不同的值。

我尝试的是打开网页,加载我的 cookie,并获取图灵值。然后用 --post-data 做另一个 wget 并将我所有的字段放在那里,包括图灵场。但它不起作用。

另外,网页上有几个表格,所以我想我必须添加表格名称。正确的?

有任何想法吗?

<form action="article.php" method="post" name="postmessage">
 <table width="100%" class="table_lines" border="0" cellspacing="0" cellpadding="6">
  <tr>
   <td>subject</td>
   <td><input type="text" name="messageinput[0]" value=""></td>
  </tr>
  <tr>
   <td>tags</td>
   <td><input type="text" name="messageinput[1]" value=""></td>
  </tr>
  <tr>
   <td>Message</td>
   <td><input type="text" name="messageinput[2]" value=""></td>
  </tr>
  <td colspan="2" align="center"><input name="mesbut" type="submit" value="Post Message" onclick="document.postmessage.mesbut.value='Posting..'; document.postmessage.mesbut.disabled=true;document.postmessage.submit();"></td>
 </table>
 <input type="hidden" name="turing" value="wgbyp">
</form>

所以我尝试的是(登录后):

/usr/bin/wget -q --load-cookies cookie.txt http://www.myurl.com/article.php -O output.html
TURING=$(sed -n -e 's/.*name="turing" value="\(.*\)">.*/\1/p' output.html)

/usr/bin/wget -q --load-cookies cookie.txt --post-data "messageinput[0]=mysubject&messageinput[1]=&messageinput[2]=mymessage&turing=${TURING}&postmessage=1&mesbut=1"  http://www.myurl.com/article.php -O output2.html

但它不起作用。

4

2 回答 2

1

The first wget needs to use --save-cookies.

Are you getting anything at all in cookie.txt in your example?

于 2014-02-14T17:01:34.627 回答
0

看来我的信息确实有效。我只是没有为网页提供足够的字段。

于 2014-02-19T10:28:02.667 回答