小编Lau*_*ren的帖子

该域名是否可用或已被占用?在 Google 表格应用脚本中

我在 Google 表格中有一个域列表。我想通过查看 Godaddy 或类似网站来了解它们是否可用。

这是应用程序脚本函数:

function domainavail(url)
{
   url = "https://www.godaddy.com/domainsearch/find?checkAvail=1&segment=repeat&domainToCheck="+url;
   var options = {
     'muteHttpExceptions': true,
     'followRedirects': false
   };
   var response = UrlFetchApp.fetch(url, options);
   var html     = response.getContentText();

   if ( html.match(/Why it's great./) )
     return "Y";
   return "N";
}
Run Code Online (Sandbox Code Playgroud)

它试图匹配文本“Why it's Great”。如果域名可用,它应该只显示在结果页面上。

但是,该函数每次都会返回“Y”,即使对于已采用的域也是如此。

你能帮我更新这个功能吗?

javascript google-sheets web-scraping google-apps-script

2
推荐指数
1
解决办法
1269
查看次数