【发布时间】:2018-03-21 12:33:46
【问题描述】:
我正在尝试从 api.wunderground.com/api 的 In the history api 中的观察数组中获取一些值。
http://api.wunderground.com/weather/api/d/docs?d=data/history
我是 JavaScript 新手,但尝试使用 json api 将这些数据提取到 Google 表格中。
我正在寻求帮助,以便从昨天的历史中获得各种观察的温度和沉淀。如果您有创造性的方式从早上 6:00 到晚上 7:00 获得 6 次(或每四分之一次)观察,则特别表扬。我只是想从白天得到一个随机集合。
// Fetch Wunderground Weather from Yesterday
var urlwx = "http://api.wunderground.com/api/" + api + "/history_" + yesterday + "/q/" + country + "/" + city + ".json" ;
var wxresponse = UrlFetchApp.fetch(urlwx);
Logger.log(urlwx)
// Parse the JSON reply
var wxcontentText = wxresponse.getContentText();
var historywx = JSON.parse(wxcontentText);
** //Get Temps this is where I'm stuck **
var yesterdayMaxTemp = historywx.history.observations[0].tempi;
var yesterdayPrecip = historywx.history.observations[0].precipi ;
【问题讨论】:
标签: javascript json google-sheets-api wunderground