我正在尝试使用Google Apps脚本从以下示例网页中提取数据:
url = http://www.premierleague.com/players/2064/Wayne-Rooney/stats?se=54
使用,UrlFetchApp.Fetch(url)
问题是当我使用UrlFetchApp.Fetch(url)来做到这一点时,我没有得到url中'se'参数定义的页面信息.相反,我获取有关以下URL的信息,因为它看起来像是异步加载'se = 54'页面:http: //www.premierleague.com/players/2064/Wayne-Rooney/stats
有没有办法以其他方式传递参数'se'?我正在查看该函数,它允许指定'选项',因为它们被引用,但有关该主题的文档非常有限.
非常感激任何的帮助.非常感谢
汤米
这似乎与许多其他问题非常相似,并且很明显错误表明我的JSON有效负载有问题.但我不知道为什么.
我正在运行Google Apps脚本来测试向Google Firebase云消息传递消息.
我的代码:
function SendGCMessage() {
var url = "https://gcm-http.googleapis.com/gcm/send";
var apiKey = "AbCdEfG";
var to = "ZyXwVuT:ToKeNtOkEnToKeNtOkEnToKeNtOkEn"
var payload = {
"data": {
"message" : "This is the message"
},
"to":to
};
var sendCount = 1;
var headers = {
"Content-Type": "application/json",
"Authorization": "key=" + apiKey
};
var params = {
headers: headers,
method: "post",
payload: payload
};
var response = UrlFetchApp.fetch(url, params);
return {message: "send completed: " + response.getContentText()};
}
Run Code Online (Sandbox Code Playgroud)
当我在调试模式下运行它时,对象有效负载看起来很好 - 就像一个普通的Javascript对象.参考也是如此.UrlFetchApp采用Javascript对象,而不是JSON表示法中的String.但是我确实尝试了"JSON.stringify(params)",我收到了一个错误.我做错了什么?
注意:当我在调试器中暂停时,params看起来像这样:
{ …
javascript json google-apps-script google-cloud-messaging firebase-cloud-messaging