From 60accec6ccaf31b94bb6c80e342e6676d1a1d85f Mon Sep 17 00:00:00 2001 From: nprasad2077 <114438461+nprasad2077@users.noreply.github.com> Date: Mon, 8 May 2023 20:03:35 -0500 Subject: [PATCH] salary scrape to db works --- nba_data/nba_scraper_salary.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/nba_data/nba_scraper_salary.py b/nba_data/nba_scraper_salary.py index 031a428..ad2e1dc 100644 --- a/nba_data/nba_scraper_salary.py +++ b/nba_data/nba_scraper_salary.py @@ -33,7 +33,7 @@ teams_test = ['HOU', 'PHI', 'BOS'] season = input('What season? ') -for team in teams_test: +for team in teams: url_make = 'https://www.basketball-reference.com/teams/' + team + '/' + season + '.html' response = requests.get(url_make) @@ -86,17 +86,17 @@ for team in teams_test: # save data to database - # for row in data: + for row in data: - # row['Salary'] = int(row['Salary'].replace(',', '').replace('$', '')) if row['Salary'] else None + row['Salary'] = int(row['Salary'].replace(',', '').replace('$', '')) if row['Salary'] else None - # player_data = PlayerSalaryData( - # player_name = row['player_name'], - # salary = row['Salary'], - # team = row['team'], - # season = row['season'], - # ) - # player_data.save() + player_data = PlayerSalaryData( + player_name = row['player_name'], + salary = row['Salary'], + team = row['team'], + season = row['season'], + ) + player_data.save() print('success')