Skip to content

Instantly share code, notes, and snippets.

@tcash21
Created July 19, 2013 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcash21/6042865 to your computer and use it in GitHub Desktop.
Save tcash21/6042865 to your computer and use it in GitHub Desktop.
import csv
import re
import sys
import urllib2
from bs4 import BeautifulSoup
page = urllib2.urlopen("http://fantasyfootballcalculator.com/completed_drafts.php?format=standard").read()
soup = BeautifulSoup(page)
#print soup.prettify()
li = []
for link in soup.find_all("a"):
li.append(link.get("href"))
def filtah(x):
return x.startswith("draft")
newlist = filter(filtah, li)
results = []
draft = newlist[1]
print draft
page = urllib2.urlopen("http://fantasyfootballcalculator.com/" + draft)
soup = BeautifulSoup(page)
table = soup.find('tbody', attrs={"id": "draftboardBody"})
rounds = table.findChildren(['tr'])
for round in rounds:
picks = round.find_all("td")
for i in range(len(picks)):
if i == len(picks) - 1:
sys.stdout.write(p + "\n")
if i == 1:
p = picks[i].text.rstrip()
sys.stdout.write("Round:" + p + ",")
else:
p = picks[i].text.rstrip()
sys.stdout.write(p + ",")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment