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

yipeiwu_com5年前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程序设计有所帮助。

相关文章

浅谈Series和DataFrame中的sort_index方法

Series 的 sort_index(ascending=True) 方法可以对 index 进行排序操作,ascending 参数用于控制升序或降序,默认为升序。 若要按值对 Ser...

使用Python3 编写简单信用卡管理程序

1、程序执行代码: #Author by Andy #_*_ coding:utf-8 _*_ import os,sys,time Base_dir=os.path.dirname...

Django 拆分model和view的实现方法

Django 拆分model和view的实现方法

在标准的dgango项目中,自动生成的目录结构会包括models.py和views.py两个文件,分别在里面写model的代码和controller的代码,但是所有的代码都写在一个文件里...

python openCV获取人脸部分并存储功能

本文实例为大家分享了python openCV获取人脸部分并存储的具体代码,供大家参考,具体内容如下 #-*- coding:utf-8 -*- import cv2 import...

python实现月食效果实例代码

python实现月食效果实例代码

我们在学习Python当中的pygame模块时,我们都知道我们可以通过使用 pygame模块实现很多功能性的东西,但是很多人应该不知道怎么通过使用pygame实现月食的效果吧,接下来我就...