@@ -0,0 +1,1352 @@
+#!/usr/bin/env python%0A#-*- coding:utf-8 -*-%0A%0Aimport httplib, urllib%0Aimport socket%0Aimport time%0A%0Aparams = dict(%0A    login_email=%22xxx%22, # replace with your email%0A    login_password=%22xxx%22, # replace with your password%0A    format=%22json%22,%0A    domain_id=xxx, # replace with your domain_od, can get it by API Domain.List%0A    record_id=xxx,#replace with your record_id, can get it by API Record.List%0A    sub_domain=%22%22, # replace with your sub_domain%0A    record_line=%22%E9%BB%98%E8%AE%A4%22,%0A)%0Acurrent_ip = None%0A%0Adef ddns(ip):%0A    params.update(dict(value=ip))%0A    headers = %7B%22Content-type%22: %22application/x-www-form-urlencoded%22, %22Accept%22: %22text/json%22%7D%0A    conn = httplib.HTTPSConnection(%22dnsapi.cn%22)%0A    conn.request(%22POST%22, %22/Record.Ddns%22, urllib.urlencode(params), headers)%0A%0A    response = conn.getresponse()%0A    print response.status, response.reason%0A    data = response.read()%0A    print data%0A    conn.close()%0A    return response.status == 200%0A%0Adef getip():%0A    sock = socket.create_connection(('ns1.dnspod.net', 6666))%0A    ip = sock.recv(16)%0A    sock.close()%0A    return ip%0A%0Aif __name__ == '__main__':%0A    while True:%0A        try:%0A            ip = getip()%0A            print ip%0A            if current_ip != ip:%0A                if ddns(ip):%0A                    current_ip = ip%0A        except Exception, e:%0A            print e%0A            pass%0A        time.sleep(600)%0A            %0A

Create get_ip_update_dnspod.py