问题
How to get Taiwan Stock Exchange Index in google spreadsheet? This index do exist in google finance under https://www.google.com/finance?q=TPE%3ATAIEX
I tried the following formula, but all of them are failed.
=GoogleFinance("TPE:TAIEX"; "price")
=GoogleFinance("TPE.TAIEX"; "price")
=GoogleFinance("TAIEX.TW"; "price")
=GoogleFinance("TAIEX:TPE"; "price")
=GoogleFinance("TAIEX.TPE"; "price")
=GoogleFinance("TPE%3ATAIEX"; "price")
回答1:
=GoogleFinance("TWII"; "price")
回答2:
I can propose you 2 work around:
The appscript trick:
build a google apps script to retrieve the data from your favorite site. Bellow an exemple with the site http://www.bloomberg.com/quote/TWSE:IND. I don't know if this exemplpe feet your need so you can change the script quite easily changing the regexp and the site url.
Please note as I'm french I need to change "," for "." that may not be necessary for you.
function twn(){
var feed = UrlFetchApp.fetch("http://www.bloomberg.com/quote/TWSE:IND"); // URL of your favorite site
var taux = feed.getContentText().match(/meta itemprop\="price" content\="[0-9,\.]*"/); // looking for a regexp in the retrieved page
taux = taux[0].slice(31,taux[0].length-1); // cleaning around what you retrieved
taux = taux.replace(",",""); // french trick
taux = taux.replace(".",","); // french trick
Logger.log("taux: "+taux); // a little log to check Is I'm not doing anything bad
return(taux); // result displayed in your spreadsheet when you call function twn()
}
The spreadsheet trick:
in your spreadsheet use the formula:=mid(REGEXEXTRACT(concatenate(Importdata("http://www.bloomberg.com/quote/TWSE:IND"));"itemprop=""price"" content=""[0-9,\.]*");27;10)
来源:https://stackoverflow.com/questions/21769645/how-to-get-taiwan-stock-exchange-index-in-google-spreadsheet