Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.