Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cookielib
- import mechanize
- br= mechanize.Browser()
- cookies = cookielib.LWPCookieJar()
- br.set_cookiejar(cookies)
- br.set_handle_equiv(True)
- br.set_handle_redirect(True)
- br.set_handle_referer(True)
- br.set_handle_robots(False)
- br.set_debug_http(False)
- br.set_debug_responses(False)
- br.set_debug_redirects(False)
- br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time = 1)
- br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
- print "Opening"
- br.open("http://www.deshabhimani.com/signin.php")
- print "Opened"
- br.select_form(name="log_in")
- br['username'] = "abc"
- br['password'] = "xyz"
- br.submit() # submit the login data
- print "Submitted"
- print(br.response().read()) # print the response
- mechanize.urlretrieve("http://www.deshabhimani.com/epaper.php?page=43210&ddate=27-07-2012&edition=Kochi","test")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement