答案 0 :(得分:0)
您需要使用BeautifulSoup
:
from bs4 import BeautifulSoup
htmlfile = urllib2.urlopen(url).read()
soup = BeautifulSoup(htmlfile)
a_tag = soup.find('a') # This finds the first occurrence of an a tag.
print a_tag['href'] # Prints the link which the a_tag links to. (hyperlink)
当然这是非常基本的代码。如果您查看模块的文档,您将看到许多其他方法可用于实现结果:)