How to get Taiwan Stock Exchange Index in google spreadsheet

自作多情 提交于 2019-12-05 21:24:01
xpawn
=GoogleFinance("TWII"; "price")

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)

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