Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import sqlite3
- import dns.resolver
- db = sqlite3.connect('ro_list.db3')
- cursor = db.cursor()
- data = cursor.execute('''
- SELECT * FROM ro_domains WHERE 'check' != 1 AND 'error' != 1
- ''')
- data = data.fetchall()
- ind = 0
- for row in data:
- mx_records = []
- ind = ind + 1
- try:
- query = dns.resolver.query(row[0],'MX')
- for rdata in query:
- mx_records.append(rdata.exchange)
- mx_to_str = " ".join(str(mx) for mx in mx_records)
- if "google" in '%s' or "GOOGLE" in '%s' % (mx_to_str):
- cursor.execute('''UPDATE ro_domains SET 'check' = 1, 'gsuite' = 1 WHERE domain = ?
- ''',(row[0],))
- status = 'apps'
- else:
- cursor.execute('''UPDATE ro_domains SET 'check' = 1, 'gsuite' = 0 WHERE domain = ?
- ''',(row[0],))
- status = 'no apps'
- except:
- cursor.execute('''UPDATE ro_domains SET 'error' = 1 WHERE domain = ?
- ''',(row[0],))
- status = 'error'
- print('{0}'.format(row[0]) + status + str(ind))
- cursor.close()
- db.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement