首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >异常: DNS错误:(第30行,文件"Code")

异常: DNS错误:(第30行,文件"Code")
EN

Stack Overflow用户
提问于 2020-05-26 02:26:37
回答 2查看 2.7K关注 0票数 0

我试图使用这个电子表格:

代码语言:javascript
复制
 https://kennymcnett.com/domain-name-checker-in-google-sheets/

我从RapidAPI获得了一个API密钥。

但是,我收到以下错误消息:

代码语言:javascript
复制
 Exception: DNS error: https://domainr.p.mashape.com/v2/status?mashape-key=f23.....25c5&domain=undefined (line 30, file "Code")

分机的第30行是:

代码语言:javascript
复制
var result = UrlFetchApp.fetch(url+domain);

扩展中的所有代码:

代码语言:javascript
复制
// Works as of April 6, 2016

// domainr docs: http://domainr.build/docs/overview

// Get your free API key from https://market.mashape.com/domainr/domainr
// Create an application, get a key
// Put your key into the cell on the "Instructions" sheet


/* sample return JSON from domainr.p.mashape.com
* 
* https://domainr.p.mashape.com/v2/status?mashape-key=YOURKEYHERE&domain=testasfkljhsdf.com
* 
* Produces:
* 
* {"status":[{"domain":"testasfkljhsdf.com","zone":"com","status":"undelegated inactive","summary":"inactive"}]}
* 
*/

function domainLookup(domain) {
  if (domain == "") {
    return "N/A";
  }

  //Get the Key from cell A11 on the sheet named "Key"
  var key = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Instructions').getRange('key').getValue(); //range = named range of the cell with the API key in it

  //Submit to mashape
  var url = "https://domainr.p.mashape.com/v2/status?mashape-key=" + key + "&domain=";
  var result = UrlFetchApp.fetch(url+domain);
  var out = JSON.parse(result.getContentText());
  var answer = out.status[0].summary;

  //Interpret the answer
  if (answer == 'undelegated' || answer == 'inactive') {
    var finalAnswer = "Available";
  } else {
    var finalAnswer = "Nope";
  }

  //Logger.log(out);
  //Logger.log(finalAnswer);

  //Show the answer
  return finalAnswer;
}

以下是电子表格中的说明:

代码语言:javascript
复制
For more detailed instructions and other information about this document, see the write-up:
http://kennymcnett.com/domain-name-checker-in-google-sheets/

Instructions

Step 1
Make a copy of this document into your own Google Drive. Then, don't change anything on this sheet except the API Key

Step 2
Get a domainr.com API key from mashape.com

Step 3
Paste your domainr API key from mashape.com below:
f236......................................b0725c5

Step 4
Go to the Domain Names sheet and have fun!

Bonus
If you want to see the script code, go to "Tools > Script editor..."For more detailed instructions and other information about this document, see the write-up:
http://kennymcnett.com/domain-name-checker-in-google-sheets/

Instructions

Step 1
Make a copy of this document into your own Google Drive. Then, don't change anything on this sheet except the API Key

Step 2
Get a domainr.com API key from mashape.com

Step 3
Paste your domainr API key from mashape.com below:
f236.........................................25c5

Step 4
Go to the Domain Names sheet and have fun!

Bonus
If you want to see the script code, go to "Tools > Script editor..."

编辑:通过将URL更改为:

domainr.p.rapidapi.com

但是,在这样做之后,我现在收到了一条新的错误消息:

Exception: Request failed for domainr.p.rapidapi.com returned code 403. Truncated server response: {"message":"You are not subscribed to this API."} (use muteHttpExceptions option to examine full response) (line 30).

我到目前为止所做的事情: 1.验证我正在使用的API是一个免费的API。根据这个URL,我使用的子域是这个api的免费版本:https://domainr.p.rapidapi.com (free or non-commercial use) source: https://domainr.com/docs/api

  1. 我验证了我不需要输入我的信用卡数据来访问免费的api,根据这个文档,免费api不要求我向我的RapidAPI帐户输入信用卡信息。

`

免费API

RapidAPI有数以千计的免费API。顾名思义,您可以在不提供信用卡细节的情况下尝试这些API中的任何一个。这些API显然是免费的。

必需的第三方API密钥

有时,您需要从提供者的网站获取API密钥或令牌。

`

source: https://docs.rapidapi.com/docs/api-pricing

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-05-26 16:14:11

这是Domainr的Eric,尝试使用domainr.p.rapidapi.com作为主机名(而不是mashape) -- RapidAPI最近出于某种原因不推荐mashape主机名。

票数 2
EN

Stack Overflow用户

发布于 2020-05-27 04:27:35

这是肯尼,你提到的博客文章的作者。如果您仍然有问题,我已经更新了博客文章,以反映几个变化,这将使您的工作。https://kennymcnett.com/domain-name-checker-in-google-sheets/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62013658

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档