高效码农

python-whois 域名whois信息查询利器

简介

python-whois一个用于查询域名whois信息的python包,比whois包速度更快、查询数据更多、更详细

功能

使用

1、安装
pip install python-whois
2、测试
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": "domain@cndns.com",
  "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': 'xxx2701@qq.com',
 '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 0
4、使用代理

部分whois服务器在国外的查询速度有些慢,如果想快一点还可以设置代理

$ pip install PySocks
$ export SOCKS=socksproxy.someplace.com:8080

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »