In the Perl world, there is WWW-mechanize module which is used as a web browser in perl to use to get load a webpage. In python there is a mechanize module that do precisely that.
To install just:
pip install mechanize
Lets assume that we have a webapp at address http://mywebapp
The code above shows how to open a page, fill in a form field, and submit it, and get the next page. It will print whole page in html, from the result of a query .
This is useful for automate access to a webpage, in my case, to test a webapp in the office. I also use this to do load test with the python multi mechanize. Pretty nifty as it is actually a browser itself.