开发者

wgetting a forum as a registered user

开发者 https://www.devze.com 2023-02-11 21:45 出处:网络
I want to sample the main page of a forum to do some statistics. The main page is only visible to registered members. How would I download it using wget? I tried logging in via a browser, then passing

I want to sample the main page of a forum to do some statistics. The main page is only visible to registered members. How would I download it using wget? I tried logging in via a browser, then passing that browser's cookie file to wget, but it doesn't work.

EDIT: Here's the login form code:

            <table border="0" cellpadding="3" cellspacing="1" width="100%">
                <tr>

                    <td colspan="2" align="center">&nbsp;</td>
                </tr>
                <tr>
                    <td width="45%" align="right"><span class="gen">User:</span></td>
                    <td><input type="text" name="username" size="25" maxlength="40" value="" class="post2" id="focus" onFocus="Active(this)" onBlur="NotActive(this)" /></td>
                </tr>
                <tr>
                    <td align="right"><span class="gen">Password:</span></td>

                    <td><input type="password" name="password" size="25" maxlength="25" class="post2" onFocus="Active(this)" onBlur="NotActive(this)" /></td>
                </tr>
                                <tr align="center">
                    <td colspan="2"><span class="gen">Remember me: <input type="checkbox" name="autologin" /></span></td>
                </tr>
                                <tr align="center">
                    <td colspan="2"><input type="hidden" name="redirect" value开发者_JS百科="" /><input type="submit" name="login" class="mainoption" value="Log in" /></td>
                </tr>

                <tr align="center">
                    <td colspan="2"><span class="gensmall"><a href="profile.php?mode=sendpassword" class="gensmall">I forgot the password</a></span></td>
                </tr>
            </table>


Wget accept some parameters like --http-user=user --http-passwd=password, aside with proxies and certificate methods. Did you try one of these ?

How does the forum authentification works ?


Look at the construction of the login form within that page. If it's a typical POST form, retrieve the names of the elements which make up the form, and construct a wget query which will pass these in to the page that the form is submitted to

In this example, the form fields are called 'username' and 'password':

wget http://www.myforum.com/login.php --post-data="username=jeffrey&password=mypassword"

You will than have downloaded just the login page. With some configuration of other wget options, you should then be able to get it to traverse to the homepage and download this (especially if there is a link to it on the post login page). You may even get lucky and your forum automatically redirects you to the main page after login; in which case, wget will download this for you at that point (depending on the type of redirection issued by the server).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号