Created
July 19, 2013 22:39
-
-
Save tcash21/6042865 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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