1
votes

Creating a ticker scanner tool on googlesheets with mainly google finance and yahoo finance. No difficulties with index(importhtml()) and other functions however I can't manage to find the correct Xpath when using importxml. I have no background in html or Xpath so I am a novice but I understand the basics behind it from troubleshooting recently.

URL: https://au.finance.yahoo.com/quote/FMG.AX?p=FMG.AX

I am trying to pull in text information about SECTOR, INDUSTRY and the DESCRIPTION which is on the right hand side (about half way down the page). It seems to be within a column which may be causing me trouble. Using Chrome inspect to retrieve XML but also tried several chrome extensions which didn't work either.

This is what I got when copying Xpath (short and long versions)

Sectors: //*[@id="Col2-11-QuoteModule-Proxy"]/div/div/div/div/p[2]

Business Summary: /html/body/div[1]/div/div/div[1]/div/div[3]/div[2]/div/div/div/div/div/div[12]/div/div/div/div/div/p

Also tried shortening the /div with //p but doesn't work anyway.

I played around and used //body/div//div/p which retrieved news data from the middle of the page.

Wondering if someone could help me adjust or explain what I am doing wrong and point me in the right direct. Any help would be greatly appreciated. Thank you so much to anyone that takes a look!

2

2 Answers

0
votes

this will never work with IMPORTXML / IMPORHTML formulae because elements you are trying to import are controlled by JavaScript which google sheets can't process.

enter image description here

0
votes

Apparently, the data you are trying to pull is controlled by JavaScript which means you won't be able to fetch it using IMPORTXML.