This is the module that I’m trying to use and there is a form I’m trying to fill automatically. The reason I’d like to use Requests over Mechanize is because with Mechanize, I have to load the login page first before I can fill it out and submit, whereas with Requests, I can skip the loading stage and go straight to POSTing the message (hopefully). Basically, I’m trying to make the login process consume as little bandwidth as possible.
My second question is, after the login process and the redirection, is it possible to not fully download the whole page, but to only retrieve the page title? Basically, the title alone will tell me if the login succeeded or not, so I want to minimize bandwidth usage.
I’m kind of a noob when it comes to HTTP requests and whatnot, so any help would be appreciated. FYI, this is for a school project.
edit The first part of the question has been answered. My question now is for the second part
Some example code:
The first step is to look at your source page and identify the
formelement that is being submitted (use Firebug/Chrome/IE tools whatever (or just looking at the source)). Then find theinputelements and identify the requirednameattributes (see above).The URL you provided happens to have a “Remember Me”, which although I haven’t tried (because I can’t), implies it’ll issue a cookie for a period of time to avoid further logins — that cookies is kept in the
request.session.Then just use
session.get(someurl, ...)to retrieve pages etc…