Skip to content
Advertisement

How to scrape table data that doesnt have different classes?

Im trying to write some code that will scrape different data from a table on a stock screener website and save the data in excel. The problem I’m having is there isn’t a distinct class code for some of the values I want to pull from the table. so I tried this only for the first header I wanted the ticker but it pulls all of the tab-links on the page. any help would be appreciated?

JavaScript

I also tried this code Ticker = [item.text for item in soup.select('.insider-buy-row-2 .tab-link')] and it did pull the ticker I wanted but it also included the persons name and other rows.

Advertisement

Answer

Use combination of pandas and BeautifulSoup

JavaScript

Important part here is pd.read_html can read multiple dataframes from <table> tags. You just have to grab the right table from the output and set the header properly.

Advertisement