1

I'm having trouble pulling the financial data from 'Book Value Per Share' using Google Sheet's IMPORTXML function

=ImportXML("https://stockanalysis.com/stocks/bby/statistics/", [Xpath])
 

Xpath:

//*[@id="main"]/div[2]/div[2]/div[4]/table/tbody/tr[6]/td[1]/span
Rubén
  • 34,714
  • 9
  • 70
  • 166
jonesmf
  • 21
  • 3

1 Answers1

-1

You can't use import xml since the page is buit using javascript. You can parse the json contained in the web page

=bookValuePerShare(A1)

with custom function

function bookValuePerShare(url) {
  var source = UrlFetchApp.fetch(url).getContentText()
  var jsonString = source.split('<script id="__NEXT_DATA__" type="application/json">')[1].split('</script>')[0]
  var data = JSON.parse(jsonString)
  result = data.props.pageProps.data.balance.data[5][2]
  return result
}
Mike Steelson
  • 14,650
  • 2
  • 5
  • 20