Back
Not sure why this isn't working :( I'm able to pull other tables from this page, just not this one.
import requestsfrom bs4 import BeautifulSoup as soupurl = requests.get("https://www.basketball-reference.com/teams/BOS/2018.html", headers={'User-Agent': 'Mozilla/5.0'})page = soup(url.content, 'html')table = page.find('table', id='team_and_opponent')print(table)
There is no table with id team_and_opponent in that page. Rather there is a span tag with this id. You can get results by changing id.
31k questions
32.8k answers
501 comments
693 users