Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- try:
- import whois
- from dateutil import relativedelta
- except ImportError:
- print("Error importing necessary modules, check if they are installed. Do: pip uninstall whois && pip install python-whois")
- exit(1)
- import datetime
- import sys
- import re
- f1=open(sys.argv[1],'r')
- o1=open("domain_output4.txt",'a')
- c=0
- for line in f1:
- c+=1
- e1=line
- if ':' in e1:
- e1=str(e1.split(':')[0])
- #print e1
- #e2=str(e1.split('.')[-2])+'.'+str(e1.split('.')[-1])
- if len(e1.split('.'))>2:
- #e2='.'.join(e1.split('.')[1:])
- e2=str(e1.split('.')[-2])+'.'+str(e1.split('.')[-1])
- e1=e2
- print str(c)+')'+e1
- if c<=0:# can skip certain lines in case we want to start the domain check from in between
- continue
- try:
- if whois_info.creation_date:
- current_date = datetime.datetime.now()
- created_on = whois_info.creation_date[0]
- diff = relativedelta.relativedelta(current_date, created_on)
- #if(int(diff.years)==0 and int(diff.months)<=2):
- print
- print domain
- print ("%s years and %s months old"%(diff.years, diff.months))
- out=line.strip()+"|%s years and %s months old\n"%(diff.years, diff.months)
- o1.write(out)
- except TypeError:
- i=0
- #print
- print domain
- print("Error calculating age difference - whois data may be missing or invalid")
- #print("%s was created %s years and %s months ago on %s" % (domain, diff.years, diff.months, created_on.strftime("%Y-%m-%d")))
- #print e1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement