I would like to login to a certain web page, and download few pages as logged in user. I think I theoretically know what to do, based on an answer to this stackoverflow question, but I have no idea, where in the address should I put the login credentials. In the question above, it is quite obvious, but it is not so obvious at Aukro.
I'd be very grateful for any avice... :)
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
You need to create HTTPS POST request supplying the following values in an
application/x-www-form-urlencoded
body:You might start by suppling values for
user_login
anduser_password
and ignore the rest, but it is impossible to know exactly what the server requries. The encoded values are certainly not reusable and if required you will have to scrape them from the login page before you login.One tricky part is the fact that this login page sets a bunch of session cookies and appends some unique query string parameters for your session. Presumably, you'll need to retrieve good values from the server for each session you create.
When you land on https://ssl.aukro.cz/enter_login.php, you get a 302 Found (which in practice is used for redirects). The full request looks like this:
You'll need to grab the URL location and the cookie it sets ("ws2"). Then you'll need to drop onto that redirect URL you grabbed, and get the rest of the cookies it sets, which are
ws2
,stsd_refr
, andqeppo_login
.You then need to fill in the POST body with the form elements as mentioned above and in the links you provided.
Not knowing anything about this site you're trying to log into, I'd venture a guess that if you don't get good session variables and cookies and include them for each of your logical requests, your login attempts may fail.
Long story short, just use Fiddler or Firebug to capture what a login session looks like, and mimic it using the techniques you've already seen.
You will need to view the source of the webpage, and find the
<form>
that is used for login. That will give you the URL that you will need to post to. You will need to specify all the variables that are in<input>
tags, just the way they did in the question you linked.In this case you will need to specify:
session, global_login_hash, session_login_hash, url, request_server, user_login, user_password
One way to determine what needs to be submitted is to use a proxy like Fiddler2, then use a web browser with its proxy set to Fiddler and log into the webpage. Fiddler will give you the request and response headers and text.
This might be a valid alternative technique
The needed controls for this are:
id="user_login"
id="user_password"
value="Přihlásit" (apparently czech for "Login")