google-sheetsgoogle-appsgoogle-sheets-apixml-import

Retrieve stock "change in percentage" in google spreadsheet with ImportXML()


I would like to retrieve stock data on Google Spreadsheet through the ImportXML() function.

Suppose I want to retrieve stock data of SHA:000001 To retrieve price, the formula to use is;

=ImportXML("https://www.google.com/finance?q=SHA:000001", "//span[@class='pr']")

What is the formula to use for retrieving "price change in percentage" for the day?


Solution

  • This worked for me:

    =ImportXML("https://www.google.com/finance?q=SHA:000001", "//div[@class='id-price-change nwp']/span/span[2]")
    

    enter image description here