2

在在这里发布问题之前,我已经进行了 2 周的研究。我可以访问它,但它需要登录才能访问内容。

我想知道如何通过 wget 登录并通过 wget 访问它的内容?这是基本的html登录。

这是网站的html代码。

<div id="loginh">
                    <div id="form">
                    <form name="frmLogin" action="/en/login.shtml" method="post">
                        <input type="hidden" name="login_attempt" value="yes">
                        <input type="hidden" name="redirect" value="/en/index.shtml">
                        <input type="text" name="login_username" class="txtBox1" title="Enter your user name" id="username" value="User name" onfocus="clickLoginField(this);" onkeypress="javascript:if ((event.which &amp;&amp; event.which == 13)||(event.keyCode &amp;&amp; event.keyCode == 13)) {document.frmLogin.login_password.focus(); return false;}">
                        <input type="password" name="login_password" class="txtBox2" title="Enter your password" id="pass" value="" onkeypress="javascript:if ((event.which &amp;&amp; event.which == 13)||(event.keyCode &amp;&amp; event.keyCode == 13)) { document.frmLogin.submit(); return false;}">
                        <input type="text" id="login_password_" name="login_password_" class="loginattemptstyle" value="">
                        <a class="login" href="javascript:void(0);" onclick="document.frmLogin.submit();">Login</a><noscript>&lt;input type="submit" value="Login"/&gt;</noscript>
                        <div class="clear"></div>
                        <table width="100%" cellpadding="5">
                            <tbody><tr>
                                <td><a href="/en/forgottenpassword.shtml" title="Have you forgotten your password?">Forgotten password?</a></td>
                                <td><table width="100%">
                                    <tbody><tr>
                                        <td><input type="checkbox" name="login_remember" style="margin-left: 0; margin-right: 5px;"></td>
                                        <td>Stay signed in</td>
                                    </tr>
                                </tbody></table></td>
                            </tr>
                        </tbody></table>
                    </form>
                    </div>
                    <script language="JavaScript" type="text/JavaScript">
                    <!--
                    $("#login_password_").val('1tCRztiXpM5jpmefqdWYn4O/ipyn5KWUneZoag==');
                    //-->
                    </script>
                </div>

我试过的

wget -q -O-  save.txt --load-cookies cookies.txt http://mysite.com/en/article1.shtml | findstr /i "'streamer'" > save3.txt
4

2 回答 2

2

您将需要执行 POST 而不是 GET REQUEST

看一下这个:

wget 发布数据中的变量

编辑:

如果你会使用 PHP,我会推荐你​​使用 Snoopy PHP http://snoopy.sourceforge.net

它模拟了一个 Web 浏览器,允许您进行进一步的机器人导航和 html 检索。它还模拟 Cookie

编辑2:

如果您不打算使用 PHP,则需要使用 CURL(下面有下载链接)。使用它,您将能够检索已发布登录页面的 html。

http://curl.haxx.se/download.html

基本用法1:http: //curl.haxx.se/docs/httpscripting.html

使用 curl 和 POST 的堆栈溢出帖子:使用 cURL 登录 POST 表单

代码示例: http ://www.yilmazhuseyin.com/blog/dev/curl-tutorial-examples-usage/

于 2013-04-02T14:31:24.437 回答
0

我使用 lynx 和 wget 来解决这个问题。请阅读这篇文章的最后一个答案。

如何使用 Wget 越过登录页面?

于 2017-10-19T08:36:12.413 回答