python使用htmllib分析网页内容的方法
时间:2021-03-06 10:13:54|栏目:Python代码|点击: 次
本文实例讲述了python使用htmllib分析网页内容的方法。分享给大家供大家参考。具体实现方法如下:
import htmllib, urllib, formatter, sys
website = urllib.urlopen("http://yourweb.com")
data = website.read()
website.close()
format = formatter.AbstractFormatter(formatter.DumbWriter(sys.stdout))
ptext = htmllib.HTMLParser(format)
ptext.feed(data)
ptext.close()
希望本文所述对大家的Python程序设计有所帮助。
上一篇:Python实现抓取HTML网页并以PDF文件形式保存的方法
栏 目:Python代码
下一篇:深入理解Python中的 __new__ 和 __init__及区别介绍
本文地址:http://www.codeinn.net/misctech/75640.html






