Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. try:
  4. import whois
  5. from dateutil import relativedelta
  6. except ImportError:
  7. print("Error importing necessary modules, check if they are installed. Do: pip uninstall whois && pip install python-whois")
  8. exit(1)
  9.  
  10. import datetime
  11. import sys
  12.  
  13. import re
  14.  
  15. f1=open(sys.argv[1],'r')
  16. o1=open("domain_output4.txt",'a')
  17. c=0
  18. for line in f1:
  19. c+=1
  20. e1=line
  21. if ':' in e1:
  22. e1=str(e1.split(':')[0])
  23. #print e1
  24. #e2=str(e1.split('.')[-2])+'.'+str(e1.split('.')[-1])
  25. if len(e1.split('.'))>2:
  26. #e2='.'.join(e1.split('.')[1:])
  27. e2=str(e1.split('.')[-2])+'.'+str(e1.split('.')[-1])
  28. e1=e2
  29. print str(c)+')'+e1
  30.  
  31. if c<=0:# can skip certain lines in case we want to start the domain check from in between
  32. continue
  33. try:
  34.  
  35.  
  36. if whois_info.creation_date:
  37. current_date = datetime.datetime.now()
  38. created_on = whois_info.creation_date[0]
  39. diff = relativedelta.relativedelta(current_date, created_on)
  40. #if(int(diff.years)==0 and int(diff.months)<=2):
  41. print
  42. print domain
  43. print ("%s years and %s months old"%(diff.years, diff.months))
  44. out=line.strip()+"|%s years and %s months old\n"%(diff.years, diff.months)
  45. o1.write(out)
  46. except TypeError:
  47. i=0
  48. #print
  49. print domain
  50. print("Error calculating age difference - whois data may be missing or invalid")
  51.  
  52. #print("%s was created %s years and %s months ago on %s" % (domain, diff.years, diff.months, created_on.strftime("%Y-%m-%d")))
  53. #print e1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement