python - Extracting a table from a website -
i've tried many times retrieve table @ website: http://www.whoscored.com/players/845/history/tomas-rosicky (the 1 under "historical participations")
import urllib2 bs4 import beautifulsoup soup = beautifulsoup(urllib2.urlopen('http://www.whoscored.com/players/845/').read()) this python code using retrieve table html, getting empty string. me out!
the desired table formed via asynchronous api call http://www.whoscored.com/statisticsfeed/1/getplayerstatistics endpoint request returns json response. in other words, urllib2 return initial html content of page without "dynamic" part. in other words, urllib2 not browser.
you can study request using browser developer tools:
now, need simulate request in code. requests package should consider using.
here similar question whoscored.com i've answered before, there sample working code can use starting point:
Comments
Post a Comment