Sahil Hussain Dar
Sahil Hussain Dar

Reputation: 21

Want to find domain age of bulk domains using python

i am working on project where i am supposed to find domain age of bulk domains using python. in python i found library called python-whois it works fine with small number of domains upto 8 domains much precisely ,after that it gives some error like voilating terms of use as this service is not for automation. i wrote the following code

import datetime
import pandas as pd
sheet=pd.read_csv('Phishing_url.csv')
x=sheet['url']
def url_age(url):
    details=whois.whois(url)
    try:
        try:
            if(len(details.creation_date)>1):
                createdate=details.creation_date[0]
            
        except:
            createdate=details.creation_date
            print(createdate)
        finally:
            today=datetime.datetime.today()
            day=today.day-createdate.day
            month=today.month-createdate.month
            year=today.year-createdate.year
            age=(year*365)+(month*30)+day
            age=age/365
            print(age)
    except:
        print("error fetching")
        
        
    return
    
    #driver
     for i in x:
            url_age(i)

which throws given output and error

0.13150684931506848
0.13150684931506848
6.328767123287672
6.328767123287672
2020-02-23 20:09:08
0.3835616438356164
Error trying to connect to socket: closing socket
None
error fetching
2020-02-24 10:23:59
0.38082191780821917
0.3780821917808219
2020-02-25 16:50:21
0.3780821917808219
2020-02-25 16:50:21
0.3780821917808219

---------------------------------------------------------------------------
PywhoisError                              Traceback (most recent call last)
<ipython-input-19-b12c93468373> in <module>
      1 for i in x:
----> 2     url_age1(i)

<ipython-input-17-d02272ed899c> in url_age1(url)
      1 def url_age1(url):
----> 2     details=whois.whois(url)
      3     try:
      4         try:
      5             if(len(details.creation_date)>1):

C:\ProgramData\Anaconda3\lib\site-packages\whois\__init__.py in whois(url, command, flags)
     42         nic_client = NICClient()
     43         text = nic_client.whois_lookup(None, domain.encode('idna'), flags)
---> 44     return WhoisEntry.load(domain, text)
     45 
     46 

C:\ProgramData\Anaconda3\lib\site-packages\whois\parser.py in load(domain, text)
    186 
    187         if domain.endswith('.com'):
--> 188             return WhoisCom(domain, text)
    189         elif domain.endswith('.net'):
    190             return WhoisNet(domain, text)

C:\ProgramData\Anaconda3\lib\site-packages\whois\parser.py in __init__(self, domain, text)
    399     def __init__(self, domain, text):
    400         if 'No match for "' in text:
--> 401             raise PywhoisError(text)
    402         else:
    403             WhoisEntry.__init__(self, domain, text)

PywhoisError: No match for "COM&AMP;[email protected]".
>>> Last update of whois database: 2020-07-13T07:14:46Z <<<

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar.  Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may 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 of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability.  VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars

Error can be summarised as "You are not authorized to access or query our Whois database through the use of electronic processes that are high-volume and automated except as reasonably necessary to register domain names or modify existing registrations"

Can anyone help me doing same procedure or can suggest alternate procedure to find age of domain.

Upvotes: 2

Views: 1448

Answers (0)

Related Questions