Python机械化-为什么可以';我不能浏览这个链接吗?

Python机械化-为什么可以';我不能浏览这个链接吗?,python,mechanize,Python,Mechanize,我正在尝试从下载一个使用mechanize的文件,以便学习将mechanize与Python结合使用 我的代码返回以下错误,我认为这意味着它找不到链接?我做错了什么 错误 File "C:\python27\lib\site-packages\mechanize-0.2.5-py2.7.egg\mechanize\_mechanize.py", line 620, in find_link raise LinkNotFoundError() 我的代码 import mechanize imp

我正在尝试从下载一个使用mechanize的文件,以便学习将mechanize与Python结合使用

我的代码返回以下错误,我认为这意味着它找不到链接?我做错了什么

错误

File "C:\python27\lib\site-packages\mechanize-0.2.5-py2.7.egg\mechanize\_mechanize.py", line 620, in find_link raise LinkNotFoundError() 
我的代码

import mechanize
import cookielib

# Browser
br = mechanize.Browser()

# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)

# Browser options
br.set_handle_equiv(True)
br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)

# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)

# Want debugging messages?
#br.set_debug_http(True)
#br.set_debug_redirects(True)
#br.set_debug_responses(True)

# User-Agent (this is cheating, ok?)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]


# Open some site, let's pick a random one, the first that pops in mind:
r = br.open('http://www.filehippo.com/download_google_chrome/')


# Show the available forms
for f in br.forms():
    print f

# Actually clicking the link
req = br.click_link(text='Download Latest Version')
br.open(req)
print br.response().read()
print br.geturl()

我建议你看看这篇关于如何从链接下载文件的文章。

链接URL发生了变化,所以我需要动态阅读,我也希望使用Mechanize。