2014-07-16 36 views

回答

3

那么,它可能不是很透彻,但仍there is what you need

import mechanize 

br = mechanize.Browser() 
br.open("http://www.example.com/") 
# follow second link with element text matching regular expression 
response1 = br.follow_link(text_regex=r"cheese\s*shop", nr=1) 

print response1.geturl() 

作为一个侧面说明,当我我正在寻找这样的方法,而且我没有在文档中找到它们,我通常会打开一个IPython shell,然后使用自动完成功能来查看是否有某种方法看起来不错。

+0

谢谢。并感谢您的建议。我一定会这么做!:) – Edasaur