Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- import pandas as pd
- import os
- offpos = ['WR', 'QB', 'RB', 'TE']
- columns = ['PLAYER', 'TEAM', 'PLAYS', 'POINTS', 'GAMES_PLAYED', 'POINTS_PER_GAME', 'RUN', 'RUSH_YARDS', 'RUSING_TD', 'PASS', 'COMPLETIONS', 'PASS_YDS', 'PASS_TD', 'FUM', 'INT']
- sfmat = {'standard' : '5', 'ppr' : '2'}
- def offassemble(year):
- if not os.path.exists(year):
- os.makedirs(year)
- for fmat in sfmat.items():
- for pos in offpos:
- url = 'http://www.thehuddle.com/stats/' + year + '/plays_std.php?ccs=' + fmat[1] + '&pos=' + pos
- df=pd.read_html(url, flavor=['bs4'])
- df=df[0]
- del df['CMP']
- del df['PYDS']
- del df['PTD']
- del df['FUM']
- del df['INT']
- df.columns = columns
- df.to_pickle(year + '/' + fmat[0] + '_' + pos + '.pkl')
- def main():
- year = input('Year?')
- offassemble(year)
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment