Skip to content

Instantly share code, notes, and snippets.

@bsmithgall
Created July 6, 2014 21:55
Show Gist options
  • Save bsmithgall/efe6efe5113af126c6d4 to your computer and use it in GitHub Desktop.
Save bsmithgall/efe6efe5113af126c6d4 to your computer and use it in GitHub Desktop.
Value of a 2014 Dollar over Time
import requests
from bs4 import BeautifulSoup
URL = "http://data.bls.gov/cgi-bin/cpicalc.pl?cost1=1.00&year1={year}&year2=2014"
# input a range of years here. The first valid year is 1913.
year_range = xrange(1939, 2014)
print [BeautifulSoup(requests.get(URL.format(year=i)).text).find('span', {'id': 'answer'}).text for i in year_range]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment