Lau*_*ren 2 javascript google-sheets web-scraping google-apps-script
我在 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”,即使对于已采用的域也是如此。
你能帮我更新这个功能吗?
如果您只想知道域是否存在,请使用注册数据访问协议 (RDAP)。这不需要一段时间来加载,因为它只返回字符串。如果域名未注册,则返回 404。如果您需要的话,还可以使用其中的详细信息,而不用支付高级服务的费用。
function domainavail(url) {
var options = {
'muteHttpExceptions': true,
'followRedirects': false
};
var html = UrlFetchApp.fetch('https://rdap.verisign.com/com/v1/domain/' + url, options).getContentText();
if(html.length == 0)
return "Y";
return "N";
}
Run Code Online (Sandbox Code Playgroud)
{"objectClassName":"domain","handle":"142504053_DOMAIN_COM-VRSN","ldhName":"YOUTUBE.COM","links":[{"value":"https:\/\/rdap.verisign.com\/com\/v1\/domain\/YOUTUBE.COM","rel":"self","href":"https:\/\/rdap.verisign.com\/com\/v1\/domain\/YOUTUBE.COM","type":"application\/rdap+json"},{"value":"https:\/\/rdap.markmonitor.com\/rdap\/domain\/YOUTUBE.COM","rel":"related","href":"https:\/\/rdap.markmonitor.com\/rdap\/domain\/YOUTUBE.COM","type":"application\/rdap+json"}],"status":["client delete prohibited","client transfer prohibited","client update prohibited","server delete prohibited","server transfer prohibited","server update prohibited"],"entities":[{"objectClassName":"entity","handle":"292","roles":["registrar"],"publicIds":[{"type":"IANA Registrar ID","identifier":"292"}],"vcardArray":["vcard",[["version",{},"text","4.0"],["fn",{},"text","MarkMonitor Inc."]]],"entities":[{"objectClassName":"entity","roles":["abuse"],"vcardArray":["vcard",[["version",{},"text","4.0"],["fn",{},"text",""],["tel",{"type":"voice"},"uri","tel:+1.2083895740"],["email",{},"text","abusecomplaints@markmonitor.com"]]]}]}],"events":[{"eventAction":"registration","eventDate":"2005-02-15T05:13:12Z"},{"eventAction":"expiration","eventDate":"2022-02-15T05:13:12Z"},{"eventAction":"last update of RDAP database","eventDate":"2021-07-09T09:23:30Z"}],"secureDNS":{"delegationSigned":false},"nameservers":[{"objectClassName":"nameserver","ldhName":"NS1.GOOGLE.COM"},{"objectClassName":"nameserver","ldhName":"NS2.GOOGLE.COM"},{"objectClassName":"nameserver","ldhName":"NS3.GOOGLE.COM"},{"objectClassName":"nameserver","ldhName":"NS4.GOOGLE.COM"}],"rdapConformance":["rdap_level_0","icann_rdap_technical_implementation_guide_0","icann_rdap_response_profile_0"],"notices":[{"title":"Terms of Use","description":["Service subject to Terms of Use."],"links":[{"href":"https:\/\/www.verisign.com\/domain-names\/registration-data-access-protocol\/terms-service\/index.xhtml","type":"text\/html"}]},{"title":"Status Codes","description":["For more information on domain status codes, please visit https:\/\/icann.org\/epp"],"links":[{"href":"https:\/\/icann.org\/epp","type":"text\/html"}]},{"title":"RDDS Inaccuracy Complaint Form","description":["URL of the ICANN RDDS Inaccuracy Complaint Form: https:\/\/icann.org\/wicf"],"links":[{"href":"https:\/\/icann.org\/wicf","type":"text\/html"}]}]}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1269 次 |
| 最近记录: |