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

yipeiwu_com6年前Python基础

本文实例讲述了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程序设计有所帮助。

相关文章

python画图--输出指定像素点的颜色值方法

如下所示: # -*- coding: utf-8 -*- #------------------------------------------------------------...

Python 实现一个颜色色值转换的小工具

Python 实现一个颜色色值转换的小工具

  需求说明   公司的 UI 设计小哥,已经转用 Zeplin 很久了。Zeplin 的设计稿展示页面的颜色色值使用十进制的 RGB 表示的,在 Android 中的颜色表示大多情况下...

在python中实现强制关闭线程的示例

如下所示: import threading import time import inspect import ctypes def _async_raise(tid, exc...

详解Django中间件的5种自定义方法

详解Django中间件的5种自定义方法

Django中间件 在http请求 到达视图函数之前 和视图函数return之后,django会根据自己的规则在合适的时机执行中间件中相应的方法。 中间件的执行流程 1、执行完所有的re...

python随机取list中的元素方法

python随机取list中的元素方法

随机取 list 中的元素 random.sample import random a = [1, 2, 3, 4, 5, 6, 7, 8, 9] b = random.sample...