2014-07-16 21 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