0

I am using mechanize (http://wwwsearch.sourceforge.net/mechanize/) to login to www.coinotron.com, but the execution hangs when I do br.submit()

import mechanize  
...  
br = mechanize.Browser()
br.open("https://coinotron.com/app?action=logon")
form = br.select_form(nr=0)
br.form["name"] = "myusername"
br.form["password"] = "mypassword"
reponse = br.submit() # HERE THE EXECUTION HANGS!

If I comment the password line then the scripts executes ok, but of course it does not login.

elena
  • 53
  • 5

1 Answers1

0

Found a workaround, although I don't completely understand why it works. But it think br.submit() was sleeping due to HTTPRefreshProcessor.honor_time = True and HTTPRefreshProcessor.max_time having a big value. So I added following line just after br = mechanize.Browser():

br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1, honor_time=True)

Following pages helped me out, although not directly related to my problem: Mechanize in Python - Redirect is not working after submit

http://wwwsearch.sourceforge.net/mechanize/hints.html

elena
  • 53
  • 5