文档

域名信息查询网站

安装

$ pip install whois

示例

import whois

domain = whois.query('www.baidu.com')
print(domain.__dict__)

输出

{
	'name': 'baidu.com',
	'tld': 'com',
	'registrar': 'MarkMonitor Inc.',
	'registrant_country': 'CN',
	'creation_date': datetime.datetime(1999, 10, 11, 11, 5, 17),
	'expiration_date': datetime.datetime(2026, 10, 11, 11, 5, 17),
	'last_updated': datetime.datetime(2022, 9, 1, 3, 54, 43),
	'status': 'clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited',
	'statuses': ['clientDeleteProhibited (https://www.icann.org/epp#clientDeleteProhibited)', 'clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited', 'clientTransferProhibited (https://www.icann.org/epp#clientTransferProhibited)', 'clientTransferProhibited https://icann.org/epp#clientTransferProhibited', 'clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited)', 'clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited', 'serverDeleteProhibited (https://www.icann.org/epp#serverDeleteProhibited)', 'serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited', 'serverTransferProhibited (https://www.icann.org/epp#serverTransferProhibited)', 'serverTransferProhibited https://icann.org/epp#serverTransferProhibited', 'serverUpdateProhibited (https://www.icann.org/epp#serverUpdateProhibited)', 'serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited'],
	'dnssec': False,
	'name_servers': ['ns1.baidu.com', 'ns2.baidu.com', 'ns3.baidu.com', 'ns4.baidu.com', 'ns7.baidu.com'],
	'registrant': 'Beijing Baidu Netcom Science Technology Co., Ltd.',
	'emails': ['abusecomplaints@markmonitor.com']
}

json序列化之后得到域名信息

{
    "name":"baidu.com",
    "tld":"com",
    "registrar":"MarkMonitor Inc.",
    "registrant_country":"CN",
    "creation_date":"1999-10-11 11:05:17",
    "expiration_date":"2026-10-11 11:05:17",
    "last_updated":"2022-09-01 03:54:43",
    "status":"clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited",
    "statuses":[
        "clientDeleteProhibited (https://www.icann.org/epp#clientDeleteProhibited)",
        "clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited",
        "clientTransferProhibited (https://www.icann.org/epp#clientTransferProhibited)",
        "clientTransferProhibited https://icann.org/epp#clientTransferProhibited",
        "clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited)",
        "clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited",
        "serverDeleteProhibited (https://www.icann.org/epp#serverDeleteProhibited)",
        "serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited",
        "serverTransferProhibited (https://www.icann.org/epp#serverTransferProhibited)",
        "serverTransferProhibited https://icann.org/epp#serverTransferProhibited",
        "serverUpdateProhibited (https://www.icann.org/epp#serverUpdateProhibited)",
        "serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited"
    ],
    "dnssec":false,
    "name_servers":[
        "ns1.baidu.com",
        "ns2.baidu.com",
        "ns3.baidu.com",
        "ns4.baidu.com",
        "ns7.baidu.com"
    ],
    "registrant":"Beijing Baidu Netcom Science Technology Co., Ltd.",
    "emails":[
        "abusecomplaints@markmonitor.com"
    ]
}