Python Mechanize keeps giving me 'response_seek_wrapper' when I try to use .open

此生再无相见时 提交于 2019-12-12 09:21:28

问题


I'm not sure what's going on, as the script used to work (before I messed around with my python on my system...)

But when I try something along the lines of

import mechanize
browser = mechanize.Browser()
browser.open("http://google.com")

I get something like

<response_seek_wrapper at 0x10123fd88 whose wrapped object = <closeable_response at 0x101232170 whose fp = <socket._fileobject object at 0x1010bf5f0>>>

Does anyone know why this is and what the fix is?

thanks!


回答1:


it's not an exception, is it?
nothing wrong is happening, you just got a return value, which is esentially a response object, equivalent to br.response().

see

>>> r = browser.open("http://google.com")
>>> r
<response_seek_wrapper at 0x9bb116c whose wrapped object = <closeable_response at 0x9bb426c whose fp = <socket._fileobject object at 0x9ba306c>>>
>>> r.info().headers
# see the response headers

vs

>>> browser.open("http://google.com")
>>> browser.response()
<response_seek_wrapper at 0x9c229cc whose wrapped object = <closeable_response at 0x9bb426c whose fp = <socket._fileobject object at 0x9ba306c>>>
>>> browser.response().info().headers
# see the response headers


来源:https://stackoverflow.com/questions/3955301/python-mechanize-keeps-giving-me-response-seek-wrapper-when-i-try-to-use-open

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!