Using Mechanize to Fill Out a Form

KDawg44 KDawg44 at gmail.com
Tue Dec 16 22:26:56 CET 2008


On Dec 16, 3:44 pm, KDawg44 <KDaw... at gmail.com> wrote:
> Hi,
>
> I am trying to use the Mechanize module to browse to a site, fill out
> a form, and login.  However, it hangs on the opening of the URL.  The
> URL is https, will this cause the open from mechanize to fail?
>
> Thanks.
>
> Kevin

Apparently, the HTTPS does not matter, but it is still hanging on the
open(URL).  I am trying to login to Yahoo!.

Code below:
#!/usr/bin/python



import urllib

import urllib2

import mechanize

baseURL = 'https://login.yahoo.com/'
br = mechanize.Browser()
br.set_handle_robots(False)
br.addheaders = [('User-Agent', 'Firefox')]
#try:
br.open(baseURL)


It just hangs until I kill it.  When I kill it, it gives me the
following traceback:

Traceback (most recent call last):
  File "FantasyHockeyLoginAndGetTeam.py", line 14, in <module>
    br.open(baseURL)
  File "build/bdist.linux-i686/egg/mechanize/_mechanize.py", line 209,
in open
  File "build/bdist.linux-i686/egg/mechanize/_mechanize.py", line 236,
in _mech_open
  File "build/bdist.linux-i686/egg/mechanize/_opener.py", line 202, in
open
  File "build/bdist.linux-i686/egg/mechanize/_http.py", line 578, in
http_response
KeyboardInterrupt


Thanks for any advice.

Kevin



More information about the Python-list mailing list