我得到了这个错误:
>>> 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>请帮帮我
谢谢
发布于 2010-10-31 17:05:17
机械化并不能保证解析所有的HTML。您可能必须手动完成此操作(这并不太难,因为这是Python)。
您是否正在尝试将查询发布到网站的search.php页面?您可以使用urllib2来实现这一点。
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...发布于 2011-05-07 20:07:25
我告诉你,这是我用来解析html的一些秘密(目标是通过机械化来强制解析html )
br = mechanize.Browser(factory=mechanize.DefaultFactory(i_want_broken_xhtml_support=True))https://stackoverflow.com/questions/4062250
复制相似问题