Skip to content

Instantly share code, notes, and snippets.

@nczz
Created August 27, 2018 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nczz/94cf3f0d150ed4c904d64045b22a5498 to your computer and use it in GitHub Desktop.
Save nczz/94cf3f0d150ed4c904d64045b22a5498 to your computer and use it in GitHub Desktop.
Gandi LiveDNS 更新腳本
#!/usr/bin/env python
import urllib3
import requests
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
urllib3.disable_warnings()
#1. 建立 API Key > https://account.gandi.net/
#2. 改 example.com > 你的網域名稱
r = requests.put('https://dns.api.gandi.net/api/v5/domains/example.com/records/%40/A',data='{"rrset_type": "A", "rrset_ttl": 300, "rrset_name": "@","rrset_values": ["%s"]}'%(s.getsockname()[0]),headers={'X-Api-Key':'gandilivednsapikey','Content-Type':'application/json'})
s.close()
print(r.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment