在谷歌表格单元格上,我只想使用以下公式获取当前的加密货币价格:
=ValueCrypto(A1)
Run Code Online (Sandbox Code Playgroud)
我为 coinmarketcap 尝试了这个功能:
function ValueCrypto(crypto) {
var url = "https://api.coinmarketcap.com/v1/ticker/" + crypto + "/?convert=EUR";
var response = UrlFetchApp.fetch(url);
var data = JSON.parse(response.getContentText());
return data[0].price_eur;
}
Run Code Online (Sandbox Code Playgroud)
该函数给我错误“我们不再在此提供此端点”
我还尝试更改端点并将 apy 密钥添加到该函数中:
function ValueCrypto(crypto) {
var url = "pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=" + crypto
var requestOptions = {
method: 'GET',
uri: 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest',
qs: {
start: 1,
limit: 5000,
convert: 'EUR'
},
headers: {
'X-CMC_PRO_API_KEY': 'myapikey'
},
json: true,
gzip: true
};
var response = UrlFetchApp.fetch(url);
var data = JSON.parse(response.getContentText());
return data[0].price_eur;
}
Run Code Online (Sandbox Code Playgroud)
现在的错误是:异常:http://pro-api.coinmarketcap.com …
我需要=importxml()每隔3分钟更新一行功能以刷新MAP小工具.
我设置函数redROWs触发每3分钟但它不起作用.任何的想法?
我有下面的脚本,它在名为价格的谷歌表中导入一些 XML 数据。一切正常,只是我设置了一个时间驱动的触发器每分钟运行一次,但数据不会更新。
我只有这个功能作为一个项目。
function getData() {
var sheetName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("prices");
var queryString = Math.random();
var cellFunction = '=ImportXML("http://myxmldata.com/data-xml.php","//data/date")';
sheetName.getRange('A2').setValue(cellFunction);
}
Run Code Online (Sandbox Code Playgroud)
那么怎么了?
我正在尝试从 Yahoo Finance 导入 Google 表格中的股票实时价格、实时交易量和平均交易量,但不确定 XPath 是否用于相同的用途。
例如,对于 URL
https://sg.finance.yahoo.com/quote/AMZN
under summary tab:
realtime price: 1910.21
volume: https://sg.finance.yahoo.com/quote/AMZN
avg. volume: 4,406,091
Run Code Online (Sandbox Code Playgroud)
在这里我尝试修改下面的代码但不确定 XPath
=INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/AMZN","//div[@id='quote-header-info']/div[last()]/div[1]"),1)
Run Code Online (Sandbox Code Playgroud) xpath ×1