Skip to content

Instantly share code, notes, and snippets.

@gabrieleromanato
Created April 18, 2022 10:09
Show Gist options
  • Save gabrieleromanato/b2b8097c031a968d37cd05c92d54a072 to your computer and use it in GitHub Desktop.
Save gabrieleromanato/b2b8097c031a968d37cd05c92d54a072 to your computer and use it in GitHub Desktop.
Cloudflare: get the NS records of a given domain via the Google DNS API
import requests
import validators
from validators import ValidationFailure
class CloudflareDNS:
def __init__(self, host):
self.host = host
self.record = 'NS'
self.api_url = 'https://dns.google/resolve?'
def resolve(self):
valid_domain = validators.domain(self.host.strip())
if isinstance(valid_domain, ValidationFailure):
return False
url = self.api_url + 'name=' + self.host + '&type=' + self.record
r = requests.get(url, allow_redirects=True)
return r.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment