Level2StockQuotes.com offers free real-time top of book quotes that I would like to capture in python using BeautifulSoup. The issue is even though I can see the actual data values in a browser inspector, I can't scrape these values into python.
BeautifulSoup returns all data rows with each data element blank. Pandas returns a dataframe with NaN for each data element.
import bs4 as bs import urllib.request import pandas as pd symbol = 'AAPL' url = 'https://markets.cboe.com/us/equities/market_statistics/book/'+ symbol + '/' page = urllib.request.urlopen(url).read() soup = bs.BeautifulSoup(page,'lxml') rows = soup.find_all('tr') print(rows) for tr in rows: td = tr.find_all('td') row =(i.text for i in td) print(row) #using pandas to get dataframe dfs = pd.read_html(url) for df in dfs: print(df)
Can someone more experienced than I tell me how to pull this data? Thanks!