如何使用google的Appscript将json数据导入Google我查看了github链接: import_json_appsscript.js和我这里有ticketmaster.com:https://app.ticketmaster.com/discovery/v2/events.json?size=1&apikey=xxxxxxx的API
我是否应该将github的代码全部链接到Appsscript中? 1:https://gist.github.com/paulgambill/cacd19da95a1421d3164
2-如何用Python或Javascript (我有json数据)的自动化方式来实现这一点,然后自动创建Google文件,然后表示其中的数据。
var url = "https://app.ticketmaster.com/discovery/v2/events.json?size=1&apikey=xxxxxxx";
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
console.log(xhr.status);
console.log(xhr.responseText);
console.log("Events");
}
};
xhr.send();发布于 2022-05-18 17:48:23
您可以使用python的gspread库来完成这一任务。看看这里的文档:https://docs.gspread.org/en/latest/#example-usage。一旦全部设置完毕,下面的代码将用于上载json
import json
import gspread
from google.oauth2.service_account import Credentials
# connect to your google sheet
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
credentials = Credentials.from_service_account_file('key.json', scopes=scope)
gc = gspread.authorize(credentials)
wks = gc.open("spreadsheet name").sheet1
# You can load a json file here, just using some sample data
x = '{ "receiver_email_1":6, "receiver_email_2":8, "receiver_email_3":10 }'
y = json.loads(x)
result = []
for key in y:
result.append([key,y[key]])
wks.update('A1', result)https://stackoverflow.com/questions/72293647
复制相似问题