python解析远程web页面的代码
更新:HHH   时间:2023-1-7


把写代码过程中经常用到的一些代码段珍藏起来,下面的代码段是关于python解析远程web页面的代码。

import htmllib, urllib, formatter, sys

def parse(url, formatter):
    f = urllib.urlopen(url)
    data = f.read()
    f.close()
    p = htmllib.HTMLParser(formatter)
    p.feed(data)
    p.close()

fmt = formatter.AbstractFormatter(formatter.DumbWriter(sys.stdout))
parse("index.htm", fmt)
返回编程语言教程...