How to get Taiwan Stock Exchange Index in google spreadsheet

血红的双手。 提交于 2019-12-07 12:59:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!