google-finance - 通过 GOOGLEFINANCE 检索 CVE-WT 的价格
问题描述
TSX 上 CVE 的价格可以=GOOGLEFINANCE("TSE:CVE", "price")
在 Google 表格中检索。如何使用 GOOGLEFINANCE 获得 CVE-WT 的价格?
解决方案
我在 googlefinance 上找不到。您可以通过 yahoo 检索:
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 test() {Logger.log(marketPrice('CVE-WT'))}
推荐阅读
- flutter - 从 Flutter 登录 google 时,帐户选择器后没有任何反应
- html - 响应性/左边距
- java - 如何根据其他线程的响应在主线程中执行某些任务?
- assembly - x86 实模式函数调用未执行
- c# - MVVM 数据绑定问题,源属性未更新
- plot - 在 GrADS 的图中添加条形图?
- python - 如何更改我选择的像素的颜色?
- python - 两个文件之间的烧瓶 url_for BuildError
- javascript - 重新发送 otp 的功能在 django 项目中不起作用
- python - 在anaconda python上导入scipy时出现FileNotFoundError