网络编程
位置:首页>> 网络编程>> Python编程>> python使用htmllib分析网页内容的方法

python使用htmllib分析网页内容的方法

作者:work24  发布时间:2022-05-22 13:28:33 

标签:python,htmllib,网页

本文实例讲述了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程序设计有所帮助。

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com