import urllib.request import ssl import json import urllib.parse ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE def get_token(host): url = f"https://{host}/api/user/login?user=admin&pass=snarfnetadmin&includeInfo=true" with urllib.request.urlopen(urllib.request.Request(url), context=ctx, timeout=8) as resp: return json.loads(resp.read().decode())['token'] token = get_token("dns1.snarfnet.net") params = { "token": token, "domain": "test.snarfnet.net", "zone": "snarfnet.net", "type": "A", "ipAddress": "140.44.4.11", "ptr": "true" } url = f"https://dns1.snarfnet.net/api/zones/records/delete?{urllib.parse.urlencode(params)}" with urllib.request.urlopen(urllib.request.Request(url), context=ctx, timeout=8) as resp: print("Delete record response:", json.loads(resp.read().decode()))