ImportXML extract paginated table into Google Sheets [duplicate] - google-sheets

This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
I would like to scrape this table url is:
https://www.londonstockexchange.com/indices/ftse-aim-all-share/constituents/table?page=1
As you can see its currently 39 pages but this can change so it's dynamic. Can someone please provide guidance on how to import it into google sheets. I have come up with the following so far:
=IMPORTXML(https://www.londonstockexchange.com/indices/ftse-aim-all-share/constituents/table?page=1", "table",1)
But it doesn't seem to work

The website you are trying to scrape is loading the table dynamically. IMPORTXML is used only for static content.
Your best bet would be to write your own script to parse it, or to find a paid service.

Related

how to scrap one of the rates in this website using google sheets' importxml formula? [duplicate]

This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
I want to get the rate of the euro from this website: bonbast.com. I tried this formula:
IMPORTXML("https://www.bonbast.com/","//tr[#id='eur1']")
but nothing imported. What is wrong with it?
As mentioned in JaSON's comment, the IMPORTXML function cannot read dynamic values generated after the page loads. It's just meant to read static pages.
The website bonbast.com seems to have an API so you can use that to retrieve the data, though it's a paid service.
By default Sheets is not really equipped to scrape dynamic websites. You're better off looking for another site that has static data, look for some kind of extension or add-on that does the work for you or learn more advanced scraping approaches.

How to get the correct XPath for ImportXML [duplicate]

This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
I tried for the past 2 hours using an xPath scraper, inspecting, googling and still can't figure this out for the life of me.
I'm trying to scrape the interest rates on this table but it's not pulling through ->
Website
https://www.fhlbboston.com/fhlbank-boston/rates#/long-term
Formula (incorrect)
importxml("https://www.fhlbboston.com/fhlbank-boston/rates#/long-term","//table",1)
import formulae of google sheets does not support the scrapping of JavaScript elements. you can always check this by disabling JS for a given site and usually only what is left can be imported. in your case:
the workaround would be to find alternative URL that hosts your desired dataset

Google Sheet importxml for Price [duplicate]

This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
I'm trying to get prices on this site, but it's always NA.
https://id.xiapibuy.com/product/51925611/16618169044
Please help me check , thanks!
=IMPORTXML(A1,"/html/body/div[1]/div/div[2]/div[1]/div/div[2]/div/div[1]/div[3]/div/div[3]/div/div/div/div/div/div/font/font")
enter image description here
if you disable JavaScript on the given URL you can see the page is empty
google sheets is not able to work with / import JS content

Google Sheets - Pull Data for investment portfolio [duplicate]

This question already has an answer here:
(Wise price comparison) IMPORTXML - Imported content is empty [duplicate]
(1 answer)
Closed 4 months ago.
I'm trying to get my investment portfolio tracker on Google Sheets going but running into a snag.
Link: https://money.tmx.com/en/quote/BCE/key-data
There is a section called "Dividend" and I want to grab the Dividend Yield and here is my code
=IMPORTXML("https://money.tmx.com/en/quote/BCE/key-data","//div[#class='sc-hLyhSY bJCEDS']/div/span")
I tried using an chrome extension called SelectorGadget, doesn't seem to work either.
This website's content is added dynamically via JavaScript, and hence it requires JavaScript to be enabled in order to render. Because of this, you cannot import its content via sheets built-in functions like IMPORTXML.
You can check that's the case if you disable JavaScript on your browser (for example, using Chrome DevTools), and then refresh the page. All you'll see is the following message:
You need to enable JavaScript to run this app.
You can also notice this if you try to import the whole body:
=IMPORTXML("https://money.tmx.com/en/quote/BCE/key-data","//body")
The imported content is the previous message as well as JavaScript code, no other HTML content.
Related threads:
How to know if Google Sheets IMPORTDATA, IMPORTFEED, IMPORTHTML or IMPORTXML functions are able to get data from a resource hosted on a website?
importXML Parse Error
Why importxml and importhtml not working here?

Google Sheets yahoo finance importXML text not td data [duplicate]

This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
On SO I often see people inquiring about how to import data from the tables on yahoo finance. I'm trying to import the business description under the profile section from yahoo finance. It seems this would require the importxml function but I'm struggling. This is my function:
=IMPORTXML("http://finance.yahoo.com/quote/AAPL/profile", "//div[#data-reactid='139']")
I think my issue is related to "div" but not sure. Might anyone be able to provide guidance? Thanks!
Sample formula:
=IMPORTXML(A1,"//h2[#data-reactid='139']/../p")
In this case, the URL of http://finance.yahoo.com/quote/AAPL/profile is put in "A1".
I used //h2[#data-reactid='139']/../p as the xpath.
Result:

Resources