# import librariesimport jsonimport requests# define endpoint and credentialsapi_key = '<redacted>'api_secret = '<redacted>'url = 'https://hibrouter/api/unbound/settings/set'setting = '{"unbound":{"dnsbl":{"enabled":"0","type":"aa,ag,sa,st","lists":"","whitelists":""},"miscellaneous":{"privatedomain":"","insecuredomain":""}}}'apply_url = "https://hibrouter/api/unbound/service/dnsbl"# request datar = requests.post(url, verify=False, data=setting, auth=(api_key, api_secret))if r.status_code == 200: response = json.loads(r.text) print(str(r.text))else: print ('Connection / Authentication issue, response received:') print (r.text)r = requests.post(apply_url, verify=False, auth=(api_key, api_secret))if r.status_code == 200: response = json.loads(r.text) print(str(r.text))else: print ('Connection / Authentication issue, response received:') print (r.text)
╰─ python3 adblock-api.py /usr/lib/python3.8/site-packages/urllib3/connectionpool.py:1043: InsecureRequestWarning: Unverified HTTPS request is being made to host 'hibrouter'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings warnings.warn({"result":"saved"}/usr/lib/python3.8/site-packages/urllib3/connectionpool.py:1043: InsecureRequestWarning: Unverified HTTPS request is being made to host 'hibrouter'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings warnings.warn({"status":"OK\n\n"}