views:

28

answers:

1

Hello, i am getting this error:

>>> br = Browser()
>>> br.open("http://www.bestforumz.com/forum/")
<response_seek_wrapper at 0x21f9fd0
whose wrapped object =
<closeable_response at 0x21f9558 whose
fp = <socket._fileobject object at
0x021F5F30>>>
>>> br.select_form(nr=0)

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    br.select_form(nr=0)
  File "build\bdist.win32\egg\mechanize\_mechanize.py", line 505, in select_form
    global_form = self._factory.global_form
  File "build\bdist.win32\egg\mechanize\_html.py", line 546, in __getattr__
    self.forms()
  File "build\bdist.win32\egg\mechanize\_html.py", line 559, in forms
    self._forms_factory.forms())
  File "build\bdist.win32\egg\mechanize\_html.py", line 228, in forms
    raise ParseError(exc)
ParseError: <unprintable ParseError object>

Please hep me out

Thanks

+1  A: 

mechanize isn't guaranteed to parse all HTML. You might have to do this by hand (which isn't too hard, this being Python).

Are you trying to post a query to the site's search.php page? You can use urllib2 for this.

import urllib2
import urllib

values = dict(foo="hello", bar="world") # examine form for actual vars
try:
    req = urllib2.Request("http://example.com/search.php",
                          urllib.urlencode(values))
    response_page = urllib2.urlopen(req).read()
except urllib2.HTTPError, details:
    pass #do something with the error here...
Ryan Ginstrom