python分析网页上的所有超级链接的代码

下边代码内容是关于python分析网页上的所有超级链接的代码,希望对小伙伴也有用。
import urllib, htmllib, formatter

data = website.read()
website.close()
format = formatter.AbstractFormatter(formatter.NullWriter())
ptext = htmllib.HTMLParser(format)
ptext.feed(data)
for link in ptext.anchorlist:
print(link)




 

posted @ 2019-05-08 13:40  Dragofly  阅读(461)  评论(0编辑  收藏  举报