For additional fun I wrote an online headline aggregator (but didn't use a dictionary in it):
#'print onlineAggregator()' - it will ask you for directory to save online file before pulling headlines def onlineAggregator(): localPath = setMediaPath() import urllib urllib.urlretrieve('http://otterrealm.com/category/news/', localPath+'\\news.html') string = open(localPath+'\\news.html', 'r').read() newString = "*** Otter Realm Breaking News! ****\n" index = 0 while index < len(string): start = string.find('<h3>', index) if start == -1: break end = string.find('</h3>', index) newString += '> ' + string[start + 4:end] + '\n' index = end + 5 return newString
No comments:
Post a Comment