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

import htmllib, urllib, formatter, sysdef 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)