Home > Blockchain >  ImpoortXML Formula in Google Sheets
ImpoortXML Formula in Google Sheets

Time:09-30

I am trying to write an XML formula in Google Sheets that scrapes the text after 'Dividend Yield'

=IMPORTXML("https://www.cnbc.com/quotes/intc", XPATH QUERY)

Xpath://*[@id="MainContentContainer"]/div/div[2]/div[1]/div[5]/div[2]/section/div[1]/ul/li[13]/span[1]

CodePudding user response:

You can retrieve the complete table of values with xpath =

//li[@class='Summary-stat']

And then retrieve de Dividend yield for instance by

=query(importxml(url,xpath),"select * where Col1='Dividend Yield' ")

You can in this way define Dividend Yield as a parameter. enter image description here

CodePudding user response:

try:

=IMPORTXML("https://www.cnbc.com/quotes/intc", 
 "/html/body/div[2]/div/div[1]/div[3]/div/div[2]/div[1]/div[5]/div[2]/section/div[1]/ul/li[13]/span[2]")

or shorter:

=IMPORTXML("https://www.cnbc.com/quotes/intc", 
 "//section/div[1]/ul/li[13]/span[2]")

enter image description here

  • Related