Skip to content

Instantly share code, notes, and snippets.

Created Apr 30, 2012
What would you like to do?
Scrape NFL
#!/usr/bin/env python
from mechanize import Browser
from BeautifulSoup import BeautifulSoup
import urllib
import urllib2
import csv
for year in range(1936, 2012):
mech = Browser()
url = ""+str(year)
page = urllib2.urlopen(url)
html =
soup = BeautifulSoup(html)
table = soup.find("table", {'class': 'data-table1'})
for row in table.findAll('tr')[1:]:
col = row.findAll('td')
selection = col[0].text
team = col[1].text
player = col[2].text
position = col[3].text
school = col[4].text
season = str(year)
draftround = "First"
record = (selection, team, player, position, school, season, draftround)
print "|".join(record)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment