[Information collection] Python implementation of front-end formatted output of whois information query and query results (12)

1. The concept of WHOIS

1.1 What is "WHOIS"

"WHOIS" is an indispensable information service in the current domain name system. When using a domain name to surf the Internet, many users want to know more about the domain name and name server details, which will use WHOIS. For the registrar of the domain name, WHOIS is often used to confirm whether the domain name data has been correctly registered to the domain name registration center (registry). Intuitively, WHOIS is a search engine linked to the domain name database, generally speaking, it is one of the name services provided and maintained by the Network Information Center (NIC).

1.2 Composition of WHOIS system

According to the requirements of IETF standards, WHOIS services are generally provided by the WHOIS system. WHOIS system is a Client/Server system. The client side is mainly responsible for:

1) Provide a user interface for accessing the WHOIS system;

2) Generate the query and send it to the Server in an appropriate format;

3) Receive the response returned by the Server and output it in a user-readable form.

The server side is mainly responsible for receiving the client's request and sending back the response data. Basic services based on the TCP protocol on the Internet have their own default TCP port numbers. For example, the default port number of the HTTP service is 80, and the default port number of the FTP service is 21. The WHOIS service, which is also one of the core services on the Internet, listens to TCP port 43 by default on its server side, receives query requests and generates responses. Generally speaking, the server side can receive three types of information queries: contacts, hosts and domain names. For the same query, the output on the server side should be consistent and stable.

Two, python-whois code implementation

# -*- coding:utf-8 -*-
"""
作者:wyt
日期:2022年04月18日
"""

import requests
from bs4 import BeautifulSoup

def 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")

return:


jd.com Domain WHOIS Lookup - WhoisSoft

















Domain 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.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:22:07Z
   Creation Date: 1992-09-29T04:00:00Z
   Registry Expiry Date: 2028-03-08T05:17:11Z
   Registrar: MarkMonitor Inc.
   Registrar IANA ID: 292
   Registrar Abuse Contact Email: [email protected]
   Registrar Abuse Contact Phone: +1.2083895740
   Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
   Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited
   Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited
   Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited
   Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited
   Name Server: NS1.JDCACHE.COM
   Name Server: NS2.JDCACHE.COM
   Name Server: NS3.JDCACHE.COM
   Name Server: NS4.JDCACHE.COM
   DNSSEC: unsigned
   URL 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: [email protected]
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-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 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/whois

If you have a legitimate interest in viewing the non-public WHOIS details, send
your request and the reasons for your request to [email protected]
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.uk

WHOIS Lookup for Your IP Address    Supported gTLDs, ccTLDs and New gTLDs

© 2009-2020 whoissoft.com All Rights Reserved.













3. Front-end implementation

If the above python code is directly placed in the views of django, the following situation will appear:
insert image description here
Therefore, use the list to format the display:

The backend generates data 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})

The backend returns data print(tih_list):
It can be seen that each row of the returned result is generated with an element in the 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\xa0
 Registrar 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 Expiration
 Date: 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 Request
 Email 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 link
 to 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,', 'and
 to 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', '', '', '', '', '', '', ''
, '', '', '', '']

Front-end display code template.html:

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

Front-end effect:
insert image description here

4. Reference

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

Guess you like

Origin blog.csdn.net/qq_45859826/article/details/124258195