2

I'm trying to use cUrl to get the contains of of a web page; but I failed because my request is automatically redirected to a sign-in page; Using the -u parameter doesn't resolve my problem.

Next the HTML listing of the sign-in page:

<ul class="form-list">
        <li>
          <label for="inputEmailLogin">E-mail</label>
        <abbr class="req">*</abbr>
          <div class="form-control">
            <input autofocus="autofocus" id="inputEmailLogin" name="user[email]" size="30" type="email" value="">   
          </div>
        </li>

        <li>
          <label for="inputPasswordLogin">Password</label>
        <abbr class="req">*</abbr>
          <div class="form-control">
            <input id="inputPasswordLogin" name="user[password]" size="30" type="password">
          </div>
        </li>
  </ul>

How can I provide my credentials so I can get the contains of the page?

Otto Barrows
  • 505
  • 1
  • 3
  • 15

1 Answers1

1

Most sites use cookie-based authentication, so you could post(or get) the username(user[email] in your case) and password to corresponding url when curl redirect to sign-in page and save cookies if it sign in successfully. Then this would help you fetch the web page.

Community
  • 1
  • 1
defool
  • 301
  • 2
  • 4
  • 1
    Some sites only accept the request with normal User-Agent/Referer in HTTP header, so you may have to find out the reason(authentication/User-Agent/Referer) for redirection in curl. – defool Mar 01 '14 at 05:15