API 查 WHOIS 的方法
筆記一下可以查到 WHOIS 的來源
WHOIS 資訊是純文字、且不同的 TLD 會有不同的格式,這對於要程式化查詢的時候會很麻煩。
方才讀文章才知道 ICANN 在推動以 RDAP 取代 WHOIS,這對於需要處理這類資訊的時候會是一大福音啊。
在有 RDAP 的前提下可以挺方便爬到資訊的:
curl -L https://rdap.org/domain/google.com.tw | jq
{
"rdapConformance": [
"rdap_level_0",
"icann_rdap_response_profile_1",
"icann_rdap_technical_implementation_guide_1"
],
"objectClassName": "domain",
"handle": "TWDOMAIN0000067325-0",
"ldhName": "google.com.tw",
"unicodeName": "google.com.tw",
"status": [
"client update prohibited",
"client transfer prohibited",
"client delete prohibited"
],
"port43": "whois.twnic.net.tw",
"links": [
{
"value": "https://ccrdap.twnic.tw/tw/domain/google.com.tw",
"href": "https://ccrdap.twnic.tw/tw/domain/google.com.tw",
"rel": "self",
"title": "Authoritative URL for this resource",
"type": "application/rdap+json"
}
],
"notices": [
],
"events": [
{
"eventAction": "registration",
"eventDate": "2000-08-29T02:22:50Z"
},
{
"eventAction": "expiration",
"eventDate": "2025-11-08T16:00:00Z"
},
{
"eventAction": "last changed",
"eventDate": "2024-10-07T09:55:19Z"
},
{
"eventAction": "last update of RDAP database",
"eventDate": "2025-08-20T14:24:34Z"
}
],
"nameservers": [ ... ],
"entities": [ ... ]
}
不過 RDAP 目前還沒全面支援,還是會需要一些第三方來源協助爬梳資訊,以前只聽說 DomainTools 付費版可以查,但也聽說價格 hen 貴;GS 的文章提及 API Ninjas 上也有提供結構化的 WHOIS 資訊,不失為一個來源。