For some reason I can't find a table by id or select the table by id.. I've been referring to the docs for BS and from what I can tell it should be working..
Below is an example of the code to try and select the table by the id "per_game", content.find(id='per_game') doesn't work for me either.
I've been referring to the find and CSS selector part of the docs, here: https://www.crummy.com/software/BeautifulSoup/bs4/doc/#find
import requests
import csv
import calendar
from datetime import date, datetime, timedelta
from collections import OrderedDict, defaultdict
from bs4 import BeautifulSoup as soup
season = str(date.today().year + 1)
month = calendar.month_name[date.today().month].lower()
teamUrl = "https://basketball-reference.com/teams/"
urls = [teamUrl + 'ATL/' + season +'.html'] # Atlanta Hawks
# teamUrl + 'BOS/' + season +'.html', # Boston Celtics
# teamUrl + 'BKN/' + season +'.html', # Brooklyn Nets
# teamUrl + 'CHA/' + season +'.html', # Charlotte Hornets
for url in urls:
page = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'})
content = soup(page.content, 'html.parser')
table = content.select("#per_game")
print(table)
Many thanks, OM.