python - beautifulsoup could not find class -
i tried use bs4 table 1 nba stat site.
the website seems did not use javascript.
the soup.prettify
print result looks normal, not use soup.find_all
table want. here's code i'm using:
import requests bs4 import beautifulsoup url = 'http://stats.nba.com/team/#!/1610612738/stats/' page = requests.get(url) html = page.content soup = beautifulsoup(html, 'html.parser') tables = soup.find_all('table')
the website loads data ajax, , data not available getting page contents beautifulsoup. however, don't need beautifulsoup @ all.
if you're using chrome, visit website , go browser's dev tools, click on network tab, click xhr filter, reload page. you'll see list of requests made:
click on , see ones you're interested in. once find 1 like, copy url, , data requests library (you included in code):
r = requests.get('http://stats.nba.com/stats/commonallplayers?isonlycurrentseason=0&leagueid=00&season=2016-17') data = r.json()
Comments
Post a Comment