Paul Graham’s Essays

Paul Graham’s Essays don’t show when they were written, so this one goes through all of the essays and finds out.

import feedparser
import re
import urllib

#Regular expression that looks for something like this: "March 2004"
date_search = re.compile('([A-Z][a-z]* 200[0-9])')

def open_url(url):
    response = urllib.urlopen(url)
    data = response.read()
    response.close()
    return data

rss_feed = feedparser.parse('http://www.aaronsw.com/2002/feeds/pgessays.rss')

for entry in rss_feed['entries']:
    print entry['title'],
    url = entry['link']
    page = open_url(url)
    dates = date_search.findall(page)
    if not dates:
        print 'Unknown'
    else:
        print dates[0]
Advertisements