Skip to content

Instantly share code, notes, and snippets.

@tomkel
Last active December 22, 2015 20:59
Show Gist options
  • Save tomkel/6530449 to your computer and use it in GitHub Desktop.
Save tomkel/6530449 to your computer and use it in GitHub Desktop.
#!/bin/python
import urllib.request, csv
from bs4 import BeautifulSoup
freedom = [[] for i in range(7)]
categoryIDs=[0,2,4,6,23,16,17]
get_url_base="http://games.espn.go.com/ffl/playertable/prebuilt/freeagency?leagueId=935815&slotCategoryId="
for categoryID in range(7):
for startIndex in range(0, 1150, 50):
get_url = get_url_base+str(categoryIDs[categoryID])+"&startIndex="+str(startIndex)
html_doc = urllib.request.urlopen(get_url)
tables = BeautifulSoup(html_doc).find_all(class_="playertablePlayerName")
for tableIterator in tables:
name = tableIterator.contents[0].string
freedom[categoryID].append(name)
if len(tables) < 50:
break
files = ['qb.csv', 'rb.csv', 'wr.csv', 'te.csv', 'flex.csv', 'dst.csv', 'k.csv']
for i in range(7):
with open(files[i]) as f:
reader = csv.reader(f)
tier = 0
for row in reader:
tier += 1
for player in row:
if player.strip() in freedom[i]:
print(files[i]+": Tier", tier,"player available: "+player)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment