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:

enter image description here

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

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -