【信息收集】whois信息查询 与 查询结果前端格式化输出的python实现(十二)

本文主要是介绍【信息收集】whois信息查询 与 查询结果前端格式化输出的python实现(十二),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

  • 一、WHOIS的概念
    • 1.1什么是“WHOIS”
    • 1.2 WHOIS系统组成
  • 二、python-whois代码实现
  • 三、前端实现
  • 四、Reference

一、WHOIS的概念

1.1什么是“WHOIS”

“WHOIS”是当前域名系统中不可或缺的一项信息服务。在使用域名进行Internet冲浪时,很多用户希望进一步了解域名、名字服务器的详细信息,这就会用到WHOIS。对于域名的注册服务机构(registrar)而言,要确认域名数据是否已经正确注册到域名注册中心(registry),也经常会用到WHOIS。直观来看,WHOIS就是链接到域名数据库的搜索引擎,一般来说是属于网络信息中心(NIC)所提供和维护的名字服务之一。

1.2 WHOIS系统组成

根据IETF标准 要求,WHOIS服务一般由WHOIS系统来提供。WHOIS系统是一个Client/Server系统。其中Client端主要负责:

1)提供访问WHOIS系统的用户接口;

2)生成查询并将其以适当的格式传送给Server;

3)接收Server传回的响应,并以用户可读的形式输出。

Server端则主要负责接收Client端的请求并发回响应数据。Internet上基于TCP协议的基本服务都有自己默认的TCP端口号,象HTTP服务的默认端口号为80,FTP服务的默认端口号为21等。同样作为Internet上核心服务之一的WHOIS服务,其Server端默认监听43号TCP端口,接收查询请求并产生响应。一般来说,Server端可以接收三种类型的信息查询:联系人、主机和域名。对于同一查询,Server端的输出应该具有一致性和稳定性。

二、python-whois代码实现

# -*- coding:utf-8 -*-
"""
作者:wyt
日期:2022年04月18日
"""import requests
from bs4 import BeautifulSoupdef test(domain):headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'}r = requests.get('http://whoissoft.com/' + domain, headers=headers)csd = r.content.decode('utf-8')soup = BeautifulSoup(csd, 'html.parser')print(soup.text)if __name__ == '__main__':test("jd.com")

返回:


jd.com Domain WHOIS Lookup - WhoisSoftDomain Name/IP Address:Global WHOIS lookup for over 220 domain name extensions,
IDN (Internationalized Domain Names) and IP addresses.Domain Name: jd.com   IP Address: 211.144.24.218/111.13.149.108/157.185.145.100/118.193.98.63/211.144.27.126Google PageRank: 0
WHOIS Lookup For Domain Name jd.com:Domain Name: JD.COMRegistry Domain ID: 101561_DOMAIN_COM-VRSNRegistrar WHOIS Server: whois.markmonitor.comRegistrar URL: http://www.markmonitor.comUpdated Date: 2022-03-10T03:22:07ZCreation Date: 1992-09-29T04:00:00ZRegistry Expiry Date: 2028-03-08T05:17:11ZRegistrar: MarkMonitor Inc.Registrar IANA ID: 292Registrar Abuse Contact Email: abusecomplaints@markmonitor.comRegistrar Abuse Contact Phone: +1.2083895740Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibitedDomain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibitedDomain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibitedDomain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibitedDomain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibitedDomain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibitedName Server: NS1.JDCACHE.COMName Server: NS2.JDCACHE.COMName Server: NS3.JDCACHE.COMName Server: NS4.JDCACHE.COMDNSSEC: unsignedURL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
>>> Last update of whois database: 2022-04-18T12:10:48Z <<<*****************************************************************************Domain Name: jd.com
Registry Domain ID: 101561_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.markmonitor.com
Registrar URL: http://www.markmonitor.com
Updated Date: 2022-03-10T03:23:40+0000
Creation Date: 1992-09-29T04:00:00+0000
Registrar Registration Expiration Date: 2028-03-08T00:00:00+0000
Registrar: MarkMonitor, Inc.
Registrar IANA ID: 292
Registrar Abuse Contact Email: abusecomplaints@markmonitor.com
Registrar Abuse Contact Phone: +1.2083895770
Domain Status: clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited)
Domain Status: clientTransferProhibited (https://www.icann.org/epp#clientTransferProhibited)
Domain Status: clientDeleteProhibited (https://www.icann.org/epp#clientDeleteProhibited)
Domain Status: serverUpdateProhibited (https://www.icann.org/epp#serverUpdateProhibited)
Domain Status: serverTransferProhibited (https://www.icann.org/epp#serverTransferProhibited)
Domain Status: serverDeleteProhibited (https://www.icann.org/epp#serverDeleteProhibited)
Registrant Organization: BEIJING JINGDONG 360 DU E-COMMERCE LTD.
Registrant State/Province: Beijing
Registrant Country: CN
Registrant Email: Select Request Email Form at https://domains.markmonitor.com/whois/jd.com
Admin Organization: BEIJING JINGDONG 360 DU E-COMMERCE LTD.
Admin State/Province: Beijing
Admin Country: CN
Admin Email: Select Request Email Form at https://domains.markmonitor.com/whois/jd.com
Tech Organization: BEIJING JINGDONG 360 DU E-COMMERCE LTD.
Tech State/Province: Beijing
Tech Country: CN
Tech Email: Select Request Email Form at https://domains.markmonitor.com/whois/jd.com
Name Server: ns1.jdcache.com
Name Server: ns2.jdcache.com
Name Server: ns4.jdcache.com
Name Server: ns3.jdcache.com
DNSSEC: unsigned
URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/
>>> Last update of WHOIS database: 2022-04-18T12:09:55+0000 <<<For more information on WHOIS status codes, please visit:https://www.icann.org/resources/pages/epp-status-codesIf you wish to contact this domain’s Registrant, Administrative, or Technical
contact, and such email address is not visible above, you may do so via our web
form, pursuant to ICANN’s Temporary Specification. To verify that you are not a
robot, please enter your email address to receive a link to a page that
facilitates email communication with the relevant contact(s).Web-based WHOIS:https://domains.markmonitor.com/whoisIf you have a legitimate interest in viewing the non-public WHOIS details, send
your request and the reasons for your request to whoisrequest@markmonitor.com
and specify the domain name in the subject line. We will review that request and
may ask for supporting documentation and explanation.The data in MarkMonitor’s WHOIS database is provided for information purposes,
and to assist persons in obtaining information about or related to a domain
name’s registration record. While MarkMonitor believes the data to be accurate,
the data is provided "as is" with no guarantee or warranties regarding its
accuracy.By submitting a WHOIS query, you agree that you will use this data only for
lawful purposes and that, under no circumstances will you use this data to:(1) allow, enable, or otherwise support the transmission by email, telephone,
or facsimile of mass, unsolicited, commercial advertising, or spam; or(2) enable high volume, automated, or electronic processes that send queries,
data, or email to MarkMonitor (or its systems) or the domain name contacts (or
its systems).MarkMonitor reserves the right to modify these terms at any time.By submitting this query, you agree to abide by this policy.MarkMonitor Domain Management(TM)
Protecting companies and consumers in a digital world.Visit MarkMonitor at https://www.markmonitor.com
Contact us at +1.8007459229
In Europe, at +44.02032062220
--WHOIS Lookup For Similar Domain Names:jd.net  jd.org  jd.cn  jd.com.cn  jd.cc  jd.co  jd.tv  jd.in  jd.de  jd.co.ukWHOIS Lookup for Your IP Address    Supported gTLDs, ccTLDs and New gTLDs© 2009-2020 whoissoft.com All Rights Reserved.

三、前端实现

如果上述python代码直接放在django的views中,会出现如下情况:
在这里插入图片描述
于是,利用 列表 进行格式化展示:

后端生成数据 views.py:

def whois(request):request.encoding = 'utf-8'message = request.POST['url']try:r = requests.get('http://whoissoft.com/' + message, headers=get_ua())csd = r.content.decode('utf-8')soup = BeautifulSoup(csd, 'html.parser')wsd = fsd.text# print('whoisr:',whoisr.text)comp = re.compile(r'a:link, a:visited {.*? }|a:hover {.*?}|white-space: .*?;|font-family:.*?;|function\s+s|window.location.href\s+=\s+".*?"|return\s+false;| var _sedoq\s+=\s+_sedoq|_sedoq.partnerid\s+=\s+''316085'';| _sedoq.locale\s+=\s+''zh-cn'';|var\s+s\s+=\s+document.createElement|s.type\s+=\s+''text/javascript'';|s.async\s+=\s+true;|s.src\s+=\s+''.*?'';|var\s+f\s+=\s+document.getElementsByTagName|f.parentNode.insertBefore|/.*?/|pre\s+{|word-wrap:\s+break-word;|}|\s*\(str1\){|\s+\+\s+str1;|\s+\|\s+\|\|\s+{;|\s+\|\|\s+{;|_sedoq.partnerid|\s+=|''316085''|\s+'';|\s+enter\s+your\s+partner\s+id|_sedoq.locale\s+=\s+|zh-cn|language\s+locale|\(function\(\)\s+{|\[0\];|s.type|text/javascript|script|s,\s+f|document.getElementById\(.*?\)|.style.marginLeft|=window|\|\||\s+{|;|en-us,|en-uk,|de-de,|es-er-fr,|pt-br,|\s+.innerWidth2|es-|er-|fr|.innerWidth2|er|-,')tih = re.sub(comp, '', soup)tih_list = tih.split('\n')return render(request, 'collect/whois.html', {'status':"yes", 'url': message, 'result': tih_list})except Exception as e:return render(request, 'collect/whois.html', {'status':"no",'url': message})

后端返回数据print(tih_list):
可看到,返回结果的每一行都被生成了列表中的一个元素。

['\ufeff', 'qq.com Domain WHOIS Lookup - WhoisSoft', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Domain Name/IP Address:', '', '', '\r', 'Global WHOIS lookup f
or ov 220 domain name extensions,\r', 'IDN (Intnationalized Domain Names) and IP addresses.\r', '', '', '', 'Domain Name: qq.com\xa0\xa0\xa0IP Address: 203.205.254.157183.3.226.35123.1
51.137.18Google PageRank: 0', 'WHOIS Lookup For Domain Name qq.com:\r', '\r', '\r', '\r', '\r', 'Domain Name: QQ.COM', '\xa0\xa0 Registry Domain ID: 2895300_DOMAIN_COM-VRSN', '\xa0\xa0Registrar WHOIS Sv: whois.markmonitor.com', '\xa0\xa0 Registrar URL: http:www.markmonitor.com', '\xa0\xa0 Updated Date: 2021-08-23T02:30:04Z', '\xa0\xa0 Creation Date: 1995-05-04T04:0
0:00Z', '\xa0\xa0 Registry Expiry Date: 2030-07-27T02:09:19Z', '\xa0\xa0 Registrar: MarkMonitor Inc.', '\xa0\xa0 Registrar IANA ID: 292', '\xa0\xa0 Registrar Abuse Contact Email: abuse
complaints@markmonitor.com', '\xa0\xa0 Registrar Abuse Contact Phone: +1.2083895740', '\xa0\xa0 Domain Status: clientDeleteProhibited https:icann.org/epp#clientDeleteProhibited', '\xa0
\xa0 Domain Status: clientTransfProhibited https:icann.org/epp#clientTransfProhibited', '\xa0\xa0 Domain Status: clientUpdateProhibited https:icann.org/epp#clientUpdateProhibited', '\x
a0\xa0 Domain Status: svDeleteProhibited https:icann.org/epp#svDeleteProhibited', '\xa0\xa0 Domain Status: svTransfProhibited https:icann.org/epp#svTransfProhibited', '\xa0\xa0 Domain
Status: svUpdateProhibited https:icann.org/epp#svUpdateProhibited', '\xa0\xa0 Name Sv: NS1.QQ.COM', '\xa0\xa0 Name Sv: NS2.QQ.COM', '\xa0\xa0 Name Sv: NS3.QQ.COM', '\xa0\xa0 Name Sv: N
S4.QQ.COM', '\xa0\xa0 DNSSEC: unsigned', '\xa0\xa0 URL of the ICANN Whois Inaccuracy Complaint Form: https:www.icann.org', '>>> Last update of whois database: 2022-04-18T12:18:34Z <<<'
, '', '*****************************************************************************', '', 'Domain Name: qq.com', 'Registry Domain ID: 2895300_DOMAIN_COM-VRSN', 'Registrar WHOIS Sv: wh
ois.markmonitor.com', 'Registrar URL: http:www.markmonitor.com', 'Updated Date: 2021-08-23T02:08:02+0000', 'Creation Date: 1995-05-04T04:00:00+0000', 'Registrar Registration ExpirationDate: 2030-07-27T02:09:19+0000', 'Registrar: MarkMonitor, Inc.', 'Registrar IANA ID: 292', 'Registrar Abuse Contact Email: abusecomplaints@markmonitor.com', 'Registrar Abuse Contact P
hone: +1.2083895770', 'Domain Status: clientUpdateProhibited (https:www.icann.org/epp#clientUpdateProhibited)', 'Domain Status: clientTransfProhibited (https:www.icann.org/epp#clientTr
ansfProhibited)', 'Domain Status: clientDeleteProhibited (https:www.icann.org/epp#clientDeleteProhibited)', 'Domain Status: svUpdateProhibited (https:www.icann.org/epp#svUpdateProhibit
ed)', 'Domain Status: svTransfProhibited (https:www.icann.org/epp#svTransfProhibited)', 'Domain Status: svDeleteProhibited (https:www.icann.org/epp#svDeleteProhibited)', 'Registrant Or
ganization: Shenzhen Tencent Comput Systems CO.,Ltd', 'Registrant State/Province: Guang Dong', 'Registrant Country: CN', 'Registrant Email: Select Request Email Form at https:domains.m
arkmonitor.comqq.com', 'Admin Organization: Shenzhen Tencent Comput Systems CO.,Ltd', 'Admin State/Province: Guang Dong', 'Admin Country: CN', 'Admin Email: Select Request Email Form a
t https:domains.markmonitor.comqq.com', 'Tech Organization: Shenzhen Tencent Comput Systems CO.,Ltd', 'Tech State/Province: Guang Dong', 'Tech Country: CN', 'Tech Email: Select RequestEmail Form at https:domains.markmonitor.comqq.com', 'Name Sv: ns4.qq.com', 'Name Sv: ns3.qq.com', 'Name Sv: ns2.qq.com', 'Name Sv: ns1.qq.com', 'DNSSEC: unsigned', 'URL of the ICANN W
HOIS Data Problem Reporting System: http:wdprs.intnic.net/', '>>> Last update of WHOIS database: 2022-04-18T12:09:19+0000 <<<', '', 'For more information on WHOIS status codes, please
visit:', '\xa0\xa0https:www.icann.orgpages/epp-status-codes', '', 'If you wish to contact this domain’s Registrant, Administrative, or Technical', 'contact, and such email address is
not visible above, you may do so via our web', 'form, pursuant to ICANN’s Temporary Specification. To vify that you are not a', 'robot, please ent your email address to receive a linkto a page that', 'facilitates email communication with the relevant contact(s).', '', 'Web-based WHOIS:', '\xa0\xa0https:domains.markmonitor.com/whois', '', 'If you have a legitimate
intest in viewing the non-public WHOIS details, send', 'your request and the reasons for your request to whoisrequest@markmonitor.com', 'and specify the domain name in the subject line
. We will review that request and', 'may ask for supporting documentation and explanation.', '', 'The data in MarkMonitor’s WHOIS database is provided for information purposes,', 'andto assist psons in obtaining information about or related to a domain', 'name’s registration record. While MarkMonitor believes the data to be accurate,', 'the data is provided "as i
s" with no guarantee or warranties regarding its', 'accuracy.', '', 'By submitting a WHOIS quy, you agree that you will use this data only for', 'lawful purposes and that, und no circu
mstances will you use this data to:', '\xa0\xa0(1) allow, enable, or othwise support the transmission by email, telephone,', 'or facsimile of mass, unsolicited, commcial advtising, or
spam or', '\xa0\xa0(2) enable high volume, automated, or electronic processes that send quies,', 'data, or email to MarkMonitor (or its systems) or the domain name contacts (or', 'its
systems).', '', 'MarkMonitor resves the right to modify these tms at any time.', '', 'By submitting this quy, you agree to abide by this policy.', '', 'MarkMonitor Domain Management(TM
)', 'Protecting companies and consums in a digital world.', '', 'Visit MarkMonitor at https:www.markmonitor.com', 'Contact us at +1.8007459229', 'In Europe, at +44.02032062220', '--\r'
, '\r', '', 'WHOIS Lookup For Similar Domain Names:qq.net\xa0\xa0qq.org\xa0\xa0qq.cn\xa0\xa0qq.com.cn\xa0\xa0qq.cc\xa0\xa0qq.co\xa0\xa0qq.tv\xa0\xa0qq.in\xa0\xa0qq.de\xa0\xa0qq.co.uk','', 'WHOIS Lookup for Your IP Address\xa0\xa0\xa0\xa0Supported gTLDs, ccTLDs and New gTLDs\r', '\r', '© 2009-2020 whoissoft.com All Rights Resved.\r', '\r', '', '', '', '', '', '', ''
, '', '', '', '']

前端展示代码template.html:

<div class="panel-body">{% for i in result %}{{ i }}<br>{% endfor %}
</div>

前端效果:
在这里插入图片描述

四、Reference

https://blog.csdn.net/weixin_34235457/article/details/92923780

这篇关于【信息收集】whois信息查询 与 查询结果前端格式化输出的python实现(十二)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/383553

相关文章

Vue3 的 shallowRef 和 shallowReactive:优化性能

大家对 Vue3 的 ref 和 reactive 都很熟悉,那么对 shallowRef 和 shallowReactive 是否了解呢? 在编程和数据结构中,“shallow”(浅层)通常指对数据结构的最外层进行操作,而不递归地处理其内部或嵌套的数据。这种处理方式关注的是数据结构的第一层属性或元素,而忽略更深层次的嵌套内容。 1. 浅层与深层的对比 1.1 浅层(Shallow) 定义

JS常用组件收集

收集了一些平时遇到的前端比较优秀的组件,方便以后开发的时候查找!!! 函数工具: Lodash 页面固定: stickUp、jQuery.Pin 轮播: unslider、swiper 开关: switch 复选框: icheck 气泡: grumble 隐藏元素: Headroom

这15个Vue指令,让你的项目开发爽到爆

1. V-Hotkey 仓库地址: github.com/Dafrok/v-ho… Demo: 戳这里 https://dafrok.github.io/v-hotkey 安装: npm install --save v-hotkey 这个指令可以给组件绑定一个或多个快捷键。你想要通过按下 Escape 键后隐藏某个组件,按住 Control 和回车键再显示它吗?小菜一碟: <template

【 html+css 绚丽Loading 】000046 三才归元阵

前言:哈喽,大家好,今天给大家分享html+css 绚丽Loading!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏+关注哦 💕 目录 📚一、效果📚二、信息💡1.简介:💡2.外观描述:💡3.使用方式:💡4.战斗方式:💡5.提升:💡6.传说: 📚三、源代码,上代码,可以直接复制使用🎥效果🗂️目录✍️

python: 多模块(.py)中全局变量的导入

文章目录 global关键字可变类型和不可变类型数据的内存地址单模块(单个py文件)的全局变量示例总结 多模块(多个py文件)的全局变量from x import x导入全局变量示例 import x导入全局变量示例 总结 global关键字 global 的作用范围是模块(.py)级别: 当你在一个模块(文件)中使用 global 声明变量时,这个变量只在该模块的全局命名空

【前端学习】AntV G6-08 深入图形与图形分组、自定义节点、节点动画(下)

【课程链接】 AntV G6:深入图形与图形分组、自定义节点、节点动画(下)_哔哩哔哩_bilibili 本章十吾老师讲解了一个复杂的自定义节点中,应该怎样去计算和绘制图形,如何给一个图形制作不间断的动画,以及在鼠标事件之后产生动画。(有点难,需要好好理解) <!DOCTYPE html><html><head><meta charset="UTF-8"><title>06

hdu1043(八数码问题,广搜 + hash(实现状态压缩) )

利用康拓展开将一个排列映射成一个自然数,然后就变成了普通的广搜题。 #include<iostream>#include<algorithm>#include<string>#include<stack>#include<queue>#include<map>#include<stdio.h>#include<stdlib.h>#include<ctype.h>#inclu

【C++】_list常用方法解析及模拟实现

相信自己的力量,只要对自己始终保持信心,尽自己最大努力去完成任何事,就算事情最终结果是失败了,努力了也不留遗憾。💓💓💓 目录   ✨说在前面 🍋知识点一:什么是list? •🌰1.list的定义 •🌰2.list的基本特性 •🌰3.常用接口介绍 🍋知识点二:list常用接口 •🌰1.默认成员函数 🔥构造函数(⭐) 🔥析构函数 •🌰2.list对象

【Prometheus】PromQL向量匹配实现不同标签的向量数据进行运算

✨✨ 欢迎大家来到景天科技苑✨✨ 🎈🎈 养成好习惯,先赞后看哦~🎈🎈 🏆 作者简介:景天科技苑 🏆《头衔》:大厂架构师,华为云开发者社区专家博主,阿里云开发者社区专家博主,CSDN全栈领域优质创作者,掘金优秀博主,51CTO博客专家等。 🏆《博客》:Python全栈,前后端开发,小程序开发,人工智能,js逆向,App逆向,网络系统安全,数据分析,Django,fastapi

活用c4d官方开发文档查询代码

当你问AI助手比如豆包,如何用python禁止掉xpresso标签时候,它会提示到 这时候要用到两个东西。https://developers.maxon.net/论坛搜索和开发文档 比如这里我就在官方找到正确的id描述 然后我就把参数标签换过来