I'm trying to find an element that's a tbody nested inside the all_totals id (it's definitely there, I checked).
import requests
from bs4 import BeautifulSoup, Comment
url = 'https://www.basketball-reference.com/players/a/abdelal01.html'
data = requests.get(url)
html = BeautifulSoup(data.text, 'html.parser')
print(html.select('#all_totals tbody').prettify())
However, this beautiful soup code just returns an empty array. I thought the problem might somehow be caused by the desired element sitting under a GIANT html comment. I added some code to attempt to parse the html to get rid of the comment:
for comment in html.findAll(text=lambda text: isinstance(text, Comment)):
comment.extract()
print(html.select('#all_totals')[0].prettify())
This worked in getting rid of the comment; however, most (but not all) of the html nested within the 'all_totals' id disappeared after doing this.
What am I doing wrong, and how can I correctly select the html that I want?