Source Code:
import pandas as pd
import requests
from bs4 import BeautifulSoup
url = 'https://basketball.realgm.com/nba/awards/by-type/Player-Of-The-Week/30'
# table-989
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
table = soup.find('table', {'class': 'tablesaw', 'data-tablesaw-mode': 'swipe'})
trs = table.find_all('tr')
rows = []
columns = ['Season', 'Player', 'Conference', 'Date',
'Team', 'Pos', 'Height', 'Weight',
'Age', 'PreDraftTeam', 'DraftYear', 'YOS']
for tr in trs[1:]:
tds = tr.find_all('td')
row = [td.text.replace('\n', '').strip() for td in tds]
rows.append(row)
df = pd.DataFrame(rows, columns=columns)
df.to_csv('Player of the week.csv', index=False)
