1from __future__ import print_function
2import urllib
3from HTMLParser import HTMLParser
4stats_upload_url = "http://www.wesnoth.org/files/dave/frogatto-stats-1.1.1/"
5
6class FrogattoStatsFilenames(HTMLParser):
7	stats_files = []
8
9	def __init__(self):
10		HTMLParser.__init__(self)
11		self.feed(urllib.urlopen(stats_upload_url).read())
12
13	def handle_starttag(self, tag, attrs):
14		if(attrs and attrs[0][0] == 'href') and attrs[0][1].endswith('.cfg'):
15			#print("tag/attrs: ", tag, attrs)
16			self.stats_files.append(attrs[0][1])
17
18print("Downloading filenames...")
19parse = FrogattoStatsFilenames()
20print("Saving {0} filenames...".format(len(parse.stats_files)))
21name_file = open("list of frogatto stats files.txt", 'w', 0)
22print(parse.stats_files, file=name_file)
23print("Done.")