Nite S
Nite S

Reputation: 13

Using ImportHTML and Google sheets for web scrape

I'm trying to scrape stock quotes from web pages using Google sheets and ImportHTML (and its variants like ImportXML and ImportData). It works on some web pages but not others. An example of a web page I'm unable to import data from is https://www.barchart.com/stocks/performance/price-change/advances.

I used the following code: =IMPORTHTML("https://www.barchart.com/stocks/performance/price-change/advances","table",0). Is there a way to download or scrape this data?

Upvotes: 1

Views: 1402

Answers (2)

Wicket
Wicket

Reputation: 38150

Tl;Dr IMPORTHMTL, IMPORTXML and IMPORTDATA can't import data from the referred webpage because it requires JavaScript be enable on the web browser.


IMPORTHMTL, IMPORTXML and IMPORTDATA are able to get data from the source code of a file on the web.

The first two requires that the HTML be well formed, they can't get data from dynamic pages.

Reference

Upvotes: 1

Luiz Lai
Luiz Lai

Reputation: 384

You have other options. You can write a simple script in any language for web scraping, using python or JS, or try the barchart API, its free.

https://www.barchart.com/ondemand/free-market-data-api

Upvotes: 2

Related Questions