如何在 java 中找出 .org 和 .in 网站的域名到期日期

How do I findout domain expiry date of a .org and .in website in java

我正在使用 WhoisClient (org.apache.commons.net.whois.WhoisClient) 来检索我的网站域到期日期。它适用于扩展名为 .com 的域。当我尝试检查我的 .org 域之一的到期日期时,结果显示 No match for domain.org。如何找出 .org.in 扩展域的到期日期?

我使用以下代码获取域的到期日期

String domainName =  mydomain.replaceFirst("^(http[s]?://www\.|http[s]?://|www\.)","");
WhoisClient whois = new WhoisClient();
whois.connect(WhoisClient.DEFAULT_HOST);
String whoisData1 = whois.query("=" + domainName);
whois.disconnect();

不要理会 whois 协议。

现在(自 2019 年 8 月 26 日起)根据 ICANN 的要求,所有 gTLD 都需要有一个 RDAP 服务器。 RDAP 就像 whois 的后继者:交换的内容相同,但这次是在 HTTPS 之上,采用一些固定的 JSON 格式。因此,解析起来很简单。

到期日期将在 "events" 数组中,并带有名为 "expiration" 的操作。

你可以去https://data.iana.org/rdap/dns.json to find out the .ORG RDAP server, it is at URL https://rdap.publicinterestregistry.net/rdap/org/

您需要更多地了解 RDAP 以了解如何使用它(查询和回复的结构),您可以在 https://about.rdap.org/

找到一些介绍

但简而言之,您的情况模拟了您需要做的事情:

$ wget -qO - https://rdap.publicinterestregistry.net/rdap/org/domain/slashdot.org | jq '.events[] | select(.eventAction | contains("expiration")) | .eventDate'
"2019-10-04T04:00:00.000Z"

PS1:如果你从whois查询中正常查询没有匹配到,那真的意味着该域不存在;也可能是因为速率限制

PS2:.IN 可能还没有 RDAP 服务器,因为它是 ccTLD,所以不受 ICANN 规则的约束。