daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Feb 19th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import sqlite3
  4. import dns.resolver
  5. db = sqlite3.connect('ro_list.db3')
  6. cursor = db.cursor()
  7. data = cursor.execute('''
  8.                SELECT * FROM ro_domains WHERE 'check' != 1 AND 'error' != 1
  9. ''')
  10. data = data.fetchall()
  11. ind = 0
  12. for row in data:
  13.     mx_records = []
  14.     ind = ind + 1
  15.     try:
  16.         query = dns.resolver.query(row[0],'MX')
  17.         for rdata in query:
  18.             mx_records.append(rdata.exchange)
  19.        
  20.         mx_to_str = " ".join(str(mx) for mx in mx_records)
  21.            
  22.         if "google" in '%s' or "GOOGLE" in '%s' % (mx_to_str):
  23.             cursor.execute('''UPDATE ro_domains SET 'check' = 1, 'gsuite' = 1 WHERE domain = ?
  24.            ''',(row[0],))
  25.             status = 'apps'
  26.         else:
  27.             cursor.execute('''UPDATE ro_domains SET 'check' = 1, 'gsuite' = 0 WHERE domain = ?
  28.            ''',(row[0],))
  29.             status = 'no apps'
  30.            
  31.     except:
  32.         cursor.execute('''UPDATE ro_domains SET 'error' = 1 WHERE domain = ?
  33.        ''',(row[0],))
  34.         status = 'error'
  35.  
  36.     print('{0}'.format(row[0]) + status + str(ind))
  37.  
  38. cursor.close()
  39. db.commit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top