Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

whois

I'm using WhoisClient (org.apache.commons.net.whois.WhoisClient) to retrieve my website domain expiry date. It is working for the domain with .com extension. When I try to check the expiry date for one of my .org domain the result says No match for domain.org. How do I find out the expiry date of a .org and .in extension domain?

I'm using the following code for getting the expiry date of the domain

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();
like image 489
Sonu Avatar asked Aug 28 '19 07:08

Sonu


People also ask

How do I find out when a domain expires?

Checking the expiration date of a domain name is an easy process, by using the whatsmydns.net domain name expiry checker tool you can quickly and easily see the expiry date of a domain.

How can I tell when a domain expires Linux?

We will use the whois command-line tool to check the domain expiry date. The whois command will return the detailed information on the domain we then need to parse the date from it using the grep command to view the expiration date.


1 Answers

Do not bother with the whois protocol.

Now (since August 26th, 2019) per ICANN requirements, all gTLDs need to have an RDAP server. RDAP is like the successor of whois: kind of the same content exchanged but this time on top of HTTPS with some fixed JSON format. Hence, trivial to parse.

The expiry date will be in the "events" array with an action called "expiration".

You can go to https://data.iana.org/rdap/dns.json to find out the .ORG RDAP server, it is at URL https://rdap.publicinterestregistry.net/rdap/org/

You need to learn a little more about RDAP to understand how to use it (structure of the query and the reply), you can find some introduction at https://about.rdap.org/

But in short your case, this emulates what you need to do:

$ 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: if you get no match from a whois query normally it really means that the domain does not exist; it could also be because of rate limiting

PS2: .IN may not have an RDAP server yet, since it is a ccTLD it is not bound by ICANN rules.

like image 122
Patrick Mevzek Avatar answered Sep 24 '22 04:09

Patrick Mevzek