Created
April 15, 2022 19:57
-
-
Save sakamer71/e39effb4a379e728a68241e078bf4aa8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 requests | |
from bs4 import BeautifulSoup | |
url = 'https://www.pro-football-reference.com' | |
year = 2021 | |
r = requests.get(url + '/years/' + str(year) + '/fantasy.htm') | |
soup = BeautifulSoup(r.content, 'html.parser') | |
parsed_table = soup.find_all('table')[0] | |
#print(parsed_table) | |
for i,row in enumerate(parsed_table.find_all('tr')[2:]): | |
dat = row.find('td', attrs={'data-stat': 'player'}) | |
if dat: | |
name = dat.a.get_text() | |
stub = dat.a.get('href') | |
else: | |
name='' | |
stub='' | |
print(name, stub) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment