@Tanaike's link to ImportXML not producing correct values answers how to workaround the issue using App Scripts.
To answer the question of "why", I believe Yahoo Finance has implemented some sort of user agent detection, such that requests from Google Spreadsheets, or more specifically requests with the user agent Mozilla/5.0 (compatible; GoogleDocs; apps-spreadsheets; +http://docs.google.com)
will be served a different (I believe older) version of the data.
When I visit the link https://finance.yahoo.com/quote/KL220121C00045000?p=KL220121C00045000 in the browser, it currently shows
As of 3:17PM EST. Market open
But when I change my user agent to mimic Google sheets, I get
As of 10:43AM EST. Market open.
Which is the same result as IMPORTXML
.
I am guessing they implemented this either to reduce fetching from automated spreadsheets, or to discourage people from scraping their sites using Google Sheets.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…