All pastes #884538 Raw Edit

Someone

public python v1 · immutable
#884538 ·published 2008-01-30 12:57 UTC
rendered paste body
#!/usr/bin/env pythonimport sys, os, os.path,htmllibclass MyParser(htmllib.HTMLParser):	def handle_starttag(tag, attrs):		print tag	dir = sys.argv[1]html_files = []def simple_walk(dir):   for file in os.listdir(dir):      filename = os.path.join(dir, file)      if os.path.isfile(filename):         if os.path.splitext(filename)[1] == ".html":            html_files.append(filename)      elif os.path.isdir(filename):         simple_walk(filename)def parse(files):	for file in html_files:		f = open(file, 'r')		data = f.read()		f.close()		MyParser.feed(data)simple_walk(dir)parse(html_files)print "HTML Files:", html_files