python实现dnspod自动更新dns解析

发布时间:2020-09-08编辑:脚本学堂
本文介绍了python dnspod自动更新dns解析的方法,python自动更新dns解析的例子,有需要的朋友参考下。

例子,python使用dnspod自动更新dns解析。
 

复制代码 代码示例:

#!/usr/bin/python
# www.jb200.com

def ddns():
"""
用当前ip更新ddns
"""
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/json"}
conn = httplib.HTTPSConnection("dnsapi.cn", timeout=30)
conn.request("POST", "/Record.Ddns", urllib.urlencode(ddns_params), headers)

response = conn.getresponse()
# print response.status, response.reason
# data = response.read()
# print data
conn.close()
return response.status == 200