Python基于whois模块简单识别网站域名及所有者的方法

时间:2019-04-14
本文章向大家介绍Python基于whois模块简单识别网站域名及所有者的方法,主要包括Python基于whois模块简单识别网站域名及所有者的方法使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

本文实例讲述了Python基于whois模块简单识别网站域名及所有者的方法。分享给大家供大家参考,具体如下:

对于一些网站,我们可能会关心其所有者是谁。为了找到网站的所有者,我们可以使用WHOIS协议查询域名的注册者是谁。Python中有一个对该协议的封装库。我们可以通过pip进行安装。

pip install python-whois

补充:本机安装了Python2与Python3两个版本,这里就使用了pip2安装python-whois模块,如下图所示:

本机Python3环境下适用pip3安装python-whois模块如下图所示:

导入模块 import whois

>>> import whois
>>> whois.whois('https://www.cgtz.com/')
{u'updated_date': datetime.datetime(2018, 3, 26, 7, 37, 52), u'status': [u'clientTransferProhibited https://icann.org/epp#clientTransferProhibited', u'clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited'], u'name': u'Nexperian Holding Limited', u'dnssec': u'unsigned', u'city': u'Hangzhou', u'expiration_date': datetime.datetime(2025, 7, 12, 18, 24, 22), u'zipcode': u'311121', u'domain_name': [u'CGTZ.COM', u'cgtz.com'], u'country': u'CN', u'whois_server': u'grs-whois.hichina.com', u'state': u'Zhejiang', u'registrar': u'HiChina Zhicheng Technology Ltd.', u'referral_url': None, u'address': u'Le Jia International No.999 Liang Mu Road Yuhang District', u'name_servers': [u'VIP1.ALIDNS.COM', u'VIP2.ALIDNS.COM'], u'org': u'Nexperian Holding Limited', u'creation_date': datetime.datetime(2008, 7, 12, 18, 24, 22), u'emails': [u'DomainAbuse@service.aliyun.com', u'YuMing@YinSiBaoHu.AliYun.com']}
>>>

补充:Python2运行结果截图如下:

Python3环境下运行效果如下:

PS:这里再为大家提供一款本站的相关工具供大家参考:

在线网站域名whois查询工具:
http://tools.jb51.net/aideddesign/whois

更多关于Python相关内容可查看本站专题:《Python Socket编程技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总

希望本文所述对大家Python程序设计有所帮助。