例外:DNS错误:(第30行,文件“代码”)

问题描述 投票:0回答:2

我正在尝试使用此电子表格:

 https://kennymcnett.com/domain-name-checker-in-google-sheets/

我从RapidAPI获得了API密钥。

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

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

扩展名的第30行是:

var result = UrlFetchApp.fetch(url+domain);

扩展名中的所有代码:

// 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;
}

这些是电子表格中的说明:

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

google-apps-script google-sheets urlfetch
2个回答
1
投票

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


0
投票

这是Kenny,您所引用的博客文章的作者。如果您仍然遇到问题,我已经更新了博客文章,以反映出一些更改可以使您的工作正常。 https://kennymcnett.com/domain-name-checker-in-google-sheets/

© www.soinside.com 2019 - 2024. All rights reserved.