-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_seasons.py
36 lines (28 loc) · 938 Bytes
/
get_seasons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
import constants
from bs4 import BeautifulSoup
import os
def get_season_data():
cur_season = constants.current_season_index
end_index = cur_season - 1
results = open("results.txt", 'w')
while cur_season > end_index:
url = constants.base_season_url.format(cur_season)
page = requests.get(url)
soup = BeautifulSoup(page.text, "lxml")
headings = soup.findAll('span', class_="pagLeagueHeading")
we_played = False
for heading in headings:
text_field = heading.text.lower()
if 'sunday' in text_field and 'rec' in text_field:
we_played = True
if we_played is True:
results.write(str(cur_season))
results.write('\n')
cur_season = cur_season - 1
results.close()
return None
if 'results.txt' in os.listdir():
os.remove('results.txt')
#get_season_data()
print("hello")