Advertisement
Guest User

Retrieve

a guest
Jul 27th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import cookielib
  2. import mechanize
  3. br= mechanize.Browser()
  4. cookies = cookielib.LWPCookieJar()
  5. br.set_cookiejar(cookies)
  6. br.set_handle_equiv(True)
  7. br.set_handle_redirect(True)
  8. br.set_handle_referer(True)
  9. br.set_handle_robots(False)
  10. br.set_debug_http(False)
  11. br.set_debug_responses(False)
  12. br.set_debug_redirects(False)
  13. br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time = 1)
  14. 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')]
  15. print "Opening"
  16. br.open("http://www.deshabhimani.com/signin.php")
  17. print "Opened"
  18. br.select_form(name="log_in")
  19. br['username'] = "abc"
  20. br['password'] = "xyz"
  21. br.submit() # submit the login data
  22. print "Submitted"
  23. print(br.response().read()) # print the response
  24. 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