Python Mechanize.Browser.Open(url)状态代码

Jam*_*mes 2 python screen-scraping mechanize web-scraping mechanize-python

我最近从perl迁移到python并且正在更新我使用perls WWW :: Mechanize使用python mechanize模块的一些脚本.

到目前为止一切都很好,但我无法在任何地方找到HTTP状态代码?(200,301等)

我用Google搜索并发现了这个,但他们不是一种只查看代码的方法吗?

使用Python中的Mechanize获取和捕获HTTP响应

谢谢.

end*_*ill 9

使用 response.code

from mechanize import Browser
browser = Browser()
response = browser.open('http://www.google.com')
print response.code
Run Code Online (Sandbox Code Playgroud)