API 请求 Google Apps 脚本
我需要从 api 请求信息。我尝试使用 UrlFetchApp.fetch 和 fetchAll 发出请求。在这两种情况下我什么也没得到。这是我的代码:(
var request1 = {
url: "https://seo-fast-audit.p.rapidapi.com/?url=" + url,
method : 'GET',
params: {url: 'https://docteurseo.fr/'},
headers: {
"x-rapidapi-host": "seo-fast-audit.p.rapidapi.com",
"x-rapidapi-key": "KEY"
}
};
let response = UrlFetchApp.fetchAll([request1])
这里我替换了密钥)
那么我的问题是什么?是异步中的问题吗功能还是我的要求不正确?
这是我正在使用的 API https://rapidapi.com/DocteurSEO/api/seo-fast-audit
I need to request information from api.I tried to make a request with UrlFetchApp.fetch and fetchAll.In both cases i got nothing.Here s my code:
var request1 = {
url: "https://seo-fast-audit.p.rapidapi.com/?url=" + url,
method : 'GET',
params: {url: 'https://docteurseo.fr/'},
headers: {
"x-rapidapi-host": "seo-fast-audit.p.rapidapi.com",
"x-rapidapi-key": "KEY"
}
};
let response = UrlFetchApp.fetchAll([request1])
(here i replaced key)
So what is my problem?Is that problem in async functions or am i requesting not correctly?
Here s API i am using
https://rapidapi.com/DocteurSEO/api/seo-fast-audit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想将以下 javascript 转换为 Google Apps 脚本,Ref
怎么样以下修改?
params
未包含在fetch
和fetchAll
的对象中。而且,我认为在您的情况下,需要url
进行 URL 编码,而com/?url=
是com?url=
。注意:
我认为上面Google Apps Script的请求与Javascript的顶部相同。但如果出现错误,请再次检查您的
KEY
。如果发生
403禁止
错误,则可能无法从Google端访问该网站。我很担心这个。参考:
If you want to convert the following javascript to Google Apps Script, Ref
how about the following modification?
params
is not included in the object forfetch
andfetchAll
. And, I thought that in your situation,url
is required to do the URL encode, andcom/?url=
iscom?url=
.Note:
I think that the request of the above Google Apps Script is the same as the top of Javascript. But if an error occurs, please check your
KEY
again.If an error of
403 forbidden
occurs, the site might not be accessed from the Google side. I'm worried about this.Reference: