0

How can we submit a password to a server and download its webpage and sub-webpage that are protected?

Because this site is frequently updated, I have to repeat opening it in a browser and submit a password for contents. Is there any way (such as wget, curl, lnyx and so on) to automate this process?

This website doesn't have a "username" but only requires to submit a "password" in a form. Then it will direct you to a sub-webpage for different contents.

Part of the source code from this website is:

    <form name="loginform" id="loginform" action="https://serveraddress/?password-protected=login" method="post">
        <p>
            <label for="password_protected_pass">Password<br />
            <input style="width:290px" type="password" name="password_protected_pwd" id="password_protected_pass" class="input" value="" size="20" tabindex="20" /></label>
        </p>

        <p class="submit">
            <input style="background-color: #782c43" type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Log In" tabindex="100" />
            <input type="hidden" name="password_protected_cookie_test" value="1" />
            <input type="hidden" name="password-protected" value="login" />
            <input type="hidden" name="redirect_to" value="https://serveraddress/introduction/" />
        </p>
    </form>

and it uses JavaScript to get elements:

  try { 
    document.getElementById('password_protected_pass').focus();
  } catch(e) {}

  if (typeof wpOnload=='function') wpOnload();

  try {
    Typekit.load({ async: true });
  } catch(e) {}

I've studied a number of questions on Stack Overflow and other places and have tried different methods, such as wget with various options: --user, --post-data, --password, --save-cookies, --keep-session-cookies or curl with similar functions, or lynx. But none of them works (submit a password in a form and download the source).

These Stack Overflow questions don't help, but can be found at example1,example,example3,example4

For example, this doesn't work for me.

wget --save-cookies cookies.txt \
     --keep-session-cookies \
     --post-data 'user=foo&password=bar' \
     --delete-after \
     http://someserver/
wget --load-cookies cookies.txt \
     http://someserver/
Ed Lucas
  • 5,955
  • 4
  • 30
  • 42
King
  • 1
  • 1
  • Please add response or error you tried with wget commands. Also some code is not well formatted, it is not very easy to read. Can you edit that? Thanks. – Benjamin Caure Aug 25 '20 at 14:02

0 Answers0