importhtml not working with URL in 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.
In a google sheets I try to read and import a table with this command:
=importhtml("https://www.hermesairports.com/flight-info/pafos/arrivals-and-departures"; "table"; 2)
result is:
#N/A
How i read the table with departures flights of the day in website https://www.hermesairports.com/flight-info/pafos/arrivals-and-departures ?

Your query is correct, but =IMPORTHTML can only import plain text, not Javascript contents
You can easily verify that the table you are interested is Javascript content by
Going on the websote https://www.hermesairports.com/flight-info/pafos/arrivals-and-departures
Click on the "lock" left from the address bar to view site permissions
The steps are slightly different depending on your browser, for Google Chrome:
Go on Permissions -> Javascript
Change the dropdown vlaue to Block
erfresh the Website
All content you cannot view when blocking Javascript is the content that you cannot import with =IMPORTHTML.

Related

ImportXML extract paginated table into Google Sheets [duplicate]

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.

IMPORTXML Function doesn't work for this page [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 do a personal search and would like to get some data (Number of players, Number of reviews, Category etc), from the single-game page of BoardGameGeek Website (https://boardgamegeek.com/boardgame/174430/gloomhaven).
Unfortunately, the IMPORTXML Google Spreadsheet function doesn't work and I don't understand why. Maybe the page is JS generated? I'm not an expert, does anyone have a solution? I have looked in other treads but it seems to me a rather specific case.
IMOPORTXML formula (or any other IMPORT formula) does not support the scrapping of JavaScript elements. you can always test this by disabling JS for a given site and usually only what is left can be imported. in your case its pure JS:

Use IMPORTXML to retrieve a table row that contains a certain term [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 use Google Sheets to import specific financial data from company filings.
Specifically, I want FFO, which you can see at the bottom of the table on page 63 here:
https://www.sec.gov/ix?doc=/Archives/edgar/data/0000888491/000088849120000048/ohi-20200930x10q.htm
I tried using
//tr[contains(.,'FFO')]/td[2])[1]
But no luck.
Every company's filing will have a different number of tables, so I can't use table index.
This page is loaded via javascript ("This application relies heavily on JavaScript, you will need to allow JavaScript to use this application." and "Below is populated dynamically VIA JS"), so importxml will be inefficient at all. Moreover, the data here are not contained in a json and are called after the page has been loaded first. See https://webapps.stackexchange.com/questions/115664/how-to-know-if-google-sheets-importdata-importfeed-importhtml-or-importxml-fun

ImportXML / ImportHTML workaround with URL Tabs on Google Sheets [duplicate]

This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
So I am trying to do a spreadsheet using Google Sheets and the importxml/html function. However, I am not seeing a solution for the URL since it has tabs on a persistent URL: https://www.morningstar.co.uk/uk/etf/snapshot/snapshot.aspx?id=0P0001CY2T&tab=3&InvestmentType=FE
My goal is to extract the tables of value & growth but not seeing a way to work around that. Only making it work on the main page of the URL: https://www.morningstar.co.uk/uk/etf/snapshot/snapshot.aspx?id=0P0001CY2T which is data I don't intend to use.
I did try to importhtml with table selection, however not displaying any data when the first URL is used. Also did try importxml with both full Xpath and Xpath for the items I'm interested in and not working either...
Options used:
=importhtml("https://www.morningstar.co.uk/uk/etf/snapshot/snapshot.aspx?id=0P0001CY2T&tab=3&InvestmentType=FE";"table";"2")
=importxml("https://www.morningstar.co.uk/uk/etf/snapshot/snapshot.aspx?id=0P0001CY2T&tab=3&InvestmentType=FE";"//#html/body/div/sal-components-pillar-cards-process/div/div[2]/div/div[3]/div[2]/div/sal-components-mip-style-measures/div/div[3]/div/div[1]/sal-components-mip-measures/div/div[2]/div/div[2]/div/div/div/table/tbody/tr[1]/td[2]")
Any ideas?
It seems that the table you are trying to fetch is controlled by Javascript which is out of hand when using IMPORTs in Google Sheets. Thus, the table can't be scraped.
You can check whether a website/table in a website is javascript controlled by doing this. Go click on the lock button on the left side of the address bar and click site settings, look for Javascript then block it. If you try and reload the website, You should notice a difference before blocking Javascript.
In this case, if you try it on your end, you will notice that after blocking Javascript on the website, you won't be able to see the tables anymore.
IMPORT functions of google sheets are not able to handle JavaScript elements. if you disable JS you are left with (and only this can be imported):

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?

Resources