Created
April 2, 2015 21:49
-
-
Save kylef/96eb24ac4c6510410240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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