Skip to content

Instantly share code, notes, and snippets.

@jaedsadadotme
Created January 24, 2023 05:28
Show Gist options
  • Save jaedsadadotme/d9e7f67adf035d11ea3f640c982946b9 to your computer and use it in GitHub Desktop.
Save jaedsadadotme/d9e7f67adf035d11ea3f640c982946b9 to your computer and use it in GitHub Desktop.
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