Looking for help! I found some code for a problem similar to my own. From a high level, I am looking to scrape multiple tables from the same webpage (for instance 'per game' and 'totals'.
Not sure if it matters, but I am using JupyterLab for this activity. I have very limited knowledge writing in Python (but trying to learn!) so I am having trouble tweaking to get what I want out of either of these websites:
https://www.sports-reference.com/cbb/players/jaden-ivey-1.html
or
https://basketball.realgm.com/player/Jaden-Ivey/Summary/148740
Essentially, this code below works for the fbref webpage but when I replace that source link with either of the above two sites above, I can't figure out how to get what I want.
import requests
from bs4 import BeautifulSoup, Comment
url = 'https://fbref.com/en/comps/9/stats/Premier-League-Stats'
soup = BeautifulSoup(requests.get(url).content, 'html.parser')
table = BeautifulSoup(soup.select_one('#all_stats_standard').find_next(text=lambda x: isinstance(x, Comment)), 'html.parser')
#print some information from the table to screen:
for tr in table.select('tr:has(td)'):
tds = [td.get_text(strip=True) for td in tr.select('td')]
print('{:<30}{:<20}{:<10}'.format(tds[0], tds[3], tds[5]))
I know there are similar questions on stackoverflow, so I aplogize if this is considered a duplicate request but I need further assistance since I'm new to this.
Thanks, Tim