Skip to content

Instantly share code, notes, and snippets.

@kylef
Created April 2, 2015 21:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylef/96eb24ac4c6510410240 to your computer and use it in GitHub Desktop.
Save kylef/96eb24ac4c6510410240 to your computer and use it in GitHub Desktop.
import requests
"""
Simple script to delete every dns entry for a cloudflare domain.
Depends on requests (pip install requests). Then fill in the
following three variables:
"""
token = 'INSERT API TOKEN'
email = 'INSERT EMAIL ADDRESS'
domain = 'INSERT DOMAIN'
def request(act, **params):
params.update({
'a': act,
'tkn': token,
'email': email,
'z': domain,
})
response = requests.post('https://www.cloudflare.com/api_json.html', params=params)
json = response.json()
if json['result'] == 'success':
if 'response' in json:
return json['response']
else:
print(json['msg'])
exit(1)
def get_domain_ids():
domains = request('rec_load_all')['recs']['objs']
return map(lambda obj: obj['rec_id'], domains)
def delete_domain(identifier):
request('rec_delete', **{'id': identifier})
if __name__ == '__main__':
map(delete_domain, get_domain_ids())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment