1
votes

I am trying to get stock information from Yahoo Finance with webscraping ImportXml Xpath,into my Google Sheet. I can get it to work with the %change, but not with the price, there I get a number I dont reconize anywhere on the page, can anybody pleas help me. My xmlImport for my Price look like this:

=INDEKS(IMPORTXML("https://finance.yahoo.com/quote/CVNA?p=CVNA";"//*[@id='quote-header-info']/div[3]/div[1]/div/span[1]");1)

And my xmlImport for my %Change look like this

=INDEKS(IMPORTXML("https://finance.yahoo.com/quote/CVNA?p=CVNA";"//*[@id='quote-header-info']/div[3]/div[1]/div/span[2]");1)

enter image description here

1
Unfortunately, I cannot understand about I can get it to work with the %change, but not with the price, there I get a number I dont reconize anywhere on the page. I apologize for this. Can I ask you about the sample output you expect? - Tanaike
I just added a screenshot to the question. I expect to get a number around 280, depending on the rate, but get the number 11.84791667 - jhjorsal
Thank you for replying. Now I noticed that the discussion has already been advanced. In this case, I would like to respect the discussion. I think that it will resolve your issue. - Tanaike

1 Answers

0
votes

try:

=REGEXEXTRACT(INDEX(IMPORTXML(
 "https://finance.yahoo.com/quote/CVNA?p=CVNA";
 "//*[@id='quote-header-info']");;3); "\d+.\d+|\d+")+0

enter image description here

enter image description here


update:

=SUBSTITUTE(REGEXEXTRACT(INDEX(IMPORTXML(
 "https://finance.yahoo.com/quote/CVNA?p=CVNA"; 
 "//*[@id='quote-header-info']");;3); "\d+.\d+|\d+"); "."; ",")*1