使错误机械化



我安装了Python 2.7, BeautifulSoup和mechanize。我打不开这一页。我得到消息:

<response_seek_wrapper at 0x2d89348L whose wrapped object =<closeable_response at 0x2d89988Lwhose fp = <socket._fileobjectobject at 0x0000000002D4CE58>>>

这是代码:

import mechanize
br=mechanize.Browser()
url = 'http://www.google.com' (or any other)
br.open(url)

我试图谷歌错误文本它,但它没有找到任何东西。这就像缺少了一些东西,但是我看了很多教程和论坛,他们只是使用开放方法而没有准备虚拟浏览器。我尝试了IDLE和命令提示符,但我得到了相同的消息。我的操作系统是Windows7。

我在这里错过了什么?

这并不意味着它不工作。它打开页面并返回您不需要使用的response对象。调用open()后继续使用br:

>>> import mechanize
>>> br = mechanize.Browser()
>>> url = 'http://www.google.com'
>>> br.open(url)
<response_seek_wrapper at 0x11164ed88 whose wrapped object = <closeable_response at 0x111653320 whose fp = <socket._fileobject object at 0x111648250>>>
>>> br.title()
'Google'

最新更新