-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
53 lines (38 loc) · 1.67 KB
/
main.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
""" Main module of Transfermarket Crawler
Given a league link, this crawler will get:
- The teams of each season
- The players of each team at each season
- The historic of each player player
"""
import parser
import leagues
import players
import managers
import teams
if __name__ == '__main__':
SEASON_START = 2006
SEASON_END = 2019
HEADER = True
for league in parser.file_read("Input/leagues.txt").split('\n'):
league_teams = leagues.get_teams(league)
for team in league_teams:
seasons = [] # new list of seasons of a team
for season in range(SEASON_START, SEASON_END):
print("Temporada: ", season)
team_players = teams.get_players(league_teams[team],
team, season)
team_info = teams.get_team_info(league_teams[team],
team, season)
managers_info = []
if team_info['Manager'] is not None:
for index, manager in enumerate(team_info['Manager']):
manager_id = team_info['Manager Id'][index]
info = managers.get_manager_info(manager, manager_id)
managers_info.append(info)
players_info = []
for player in team_players:
players_info.append(players.get_player_info(
team_players[player], player))
parser.file_write(team_info, players_info,
managers_info, HEADER)
HEADER = False