Skip to content

Instantly share code, notes, and snippets.

View docblades's full-sized avatar

Christian Blades docblades

View GitHub Profile
@neilkod
neilkod / nationaldebt.py
Created January 31, 2011 02:04
retrieves and prints the national debt and us population
from BeautifulSoup import BeautifulSoup
import urllib2
page = urllib2.urlopen('http://www.treasurydirect.gov/NP/BPDLogin?application=np')
soup = BeautifulSoup(page)
debt = soup.find('table',{'class':'data1'}).findAll('td')[3].text
asof = soup.find('table',{'class':'data1'}).findAll('td')[0].text
population_url = 'http://www.census.gov/main/www/popclock.html'
population_page = urllib2.urlopen(population_url)
soup = BeautifulSoup(population_page)