I have the following code:
url = 'https://www.basketball-reference.com/leagues/NBA_2017_standings.html#all_expanded_standings'
html = urlopen(url)
soup = BeautifulSoup(html, 'lxml')
print(len(soup.findAll('table')))
print(soup.findAll('table'))
There are 6 tables on the webpage, but it only returns 4 tables. I tried to use 'html.parser' or 'html5lib' as parsers but did not work either.
Any idea how I can get the Table "expanded standings" from the webpage?
Thanks!
requests
can't fetch data that are loaded byJS
. So, you have to useselenium
. First installselenium
viapip
-pip install selenium
and download chrome driver and put the file in your working directory. Then try the following code.See
selenium
documentation.If you are on
Linux
and get errorChromedriver executable needs to be in the PATH
then try following these ways - link-1, link-2