域名怎么查(python)

简介python-whois一个用于查询域名whois信息的python包,比whois包速度更快、查询数据更多、更详细功能一个简单的可导入Python模块,该模块将为给定域生成已解析的WHOIS数据。能够提取所有主流的TLD(com,org,net等)的数据直接查询WHOIS服务器,而不是像其他许多服务一样通过中间Web服务。适用于Python 2和3使用1、安装pip install python-whois2、测试python3 -m unittest discover test输出:{
"domain_name": [
"YNFMACHINERYPARTS.COM",
"ynfmachineryparts.com"
],
"registrar": "SHANGHAI MEICHENG TECHNOLOGY INFORMATION DEVELOPMENT CO., LTD.",
"whois_server": "grs-whois.cndns.com",
"referral_url": null,
"updated_date": [
"2020-12-08 07:49:14",
"2019-08-14 12:18:03"
],
"creation_date": "2018-02-03 00:37:32",
"expiration_date": [
"2025-02-03 00:37:32",
"2025-02-03 08:37:32"
],
"name_servers": [
"NS1.ES1003.SITEGROUND.EU",
"NS2.ES1003.SITEGROUND.EU"
],
"status": [
"clientTransferProhibited https://icann.org/epp#clientTransferProhibited",
"ok https://icann.org/epp#ok"
],
"emails": "[email protected]",
"dnssec": "unsigned",
"name": null,
"org": null,
"address": null,
"city": null,
"state": "Shanghai",
"zipcode": null,
"country": "cn"
}
[datetime.datetime(2025, 2, 3, 0, 37, 32), datetime.datetime(2025, 2, 3, 8, 37, 32)]

———————————————————————-
Ran 0 tests in 0.000s
3、使用示例import pprint
import whois

domain = whois.whois('xugj520.cn')
pprint.pprint(domain)
print('name: ' + domain.domain_name)输出:{'creation_date': datetime.datetime(2019, 3, 5, 22, 27, 20),
'dnssec': 'unsigned',
'domain_name': 'xugj520.cn',
'emails': '[email protected]',
'expiration_date': datetime.datetime(2022, 3, 5, 22, 27, 20),
'name': 'xxx',
'name_servers': ['f1g1ns1.dnspod.net', 'f1g1ns2.dnspod.net'],
'registrar': '北京新网数码信息技术有限公司',
'status': 'ok'}
name: xugj520.cn

Process finished with exit code 04、使用代理部分whois服务器在国外的查询速度有些慢,如果想快一点还可以设置代理$ pip install PySocks
$ export SOCKS=socksproxy.someplace.com:8080


本文出自快速备案,转载时请注明出处及相应链接。

本文永久链接: https://www.xiaosb.com/beian/37560/