In yahoo finance, since the page is built by the mean of javascript, you can't use native import functions.
However, there is a big json that you can parse
var url='https://finance.yahoo.com/quote/'+code
var source = UrlFetchApp.fetch(url).getContentText()
var jsonString = source.match(/(?<=root.App.main = ).*(?=}}}})/g) + '}}}}'
var data = JSON.parse(jsonString)
you can fetch for instance the regularMarketPrice
var regularMarketPrice = data.context.dispatcher.stores.StreamDataStore.quoteData[code].regularMarketPrice.raw
or dividend rate
var dividendRate = data.context.dispatcher.stores.QuoteSummaryStore.summaryDetail.dividendRate.raw
application
in your sheet =dividend("SAF.PA")
or =marketPrice("SAF.PA")
with these custom functions
function marketPrice(code) {
var url='https://finance.yahoo.com/quote/'+code
var source = UrlFetchApp.fetch(url).getContentText()
var jsonString = source.match(/(?<=root.App.main = ).*(?=}}}})/g) + '}}}}'
var data = JSON.parse(jsonString)
var regularMarketPrice = data.context.dispatcher.stores.StreamDataStore.quoteData[code].regularMarketPrice.raw
return regularMarketPrice
}
function dividend(code) {
var url='https://finance.yahoo.com/quote/'+code
var source = UrlFetchApp.fetch(url).getContentText()
var jsonString = source.match(/(?<=root.App.main = ).*(?=}}}})/g) + '}}}}'
var data = JSON.parse(jsonString)
var dividendRate = data.context.dispatcher.stores.QuoteSummaryStore.summaryDetail.dividendRate.raw
return dividendRate
}
//*[@id='quote-summary']//tr[6])[2]/td[2]
. Not spent a lot of time looking at more robust paths but that is certainly better than a long fragile path. – Swordfish