Created
August 27, 2018 14:53
-
-
Save nczz/94cf3f0d150ed4c904d64045b22a5498 to your computer and use it in GitHub Desktop.
Gandi LiveDNS 更新腳本
This file contains 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
#!/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