-
-
Save jaedsadadotme/d9e7f67adf035d11ea3f640c982946b9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
import json | |
import urllib.request | |
from requests import get | |
def getIp(): | |
return get('https://api.ipify.org').content.decode('utf8') | |
def patchDNSRecord(key,zoneId,dnsId): | |
url = "https://api.cloudflare.com/client/v4/zones/"+zoneId+"/dns_records/"+dnsId | |
payload = json.dumps({ | |
"content": getIp() | |
}) | |
headers = { | |
'Content-Type': 'application/json', | |
'Accept': 'application/json', | |
'Authorization': 'Bearer '+key, | |
} | |
response = requests.request("PATCH", url, headers=headers, data=payload) | |
print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment