domain_id = xxx , # 换成你的domian_id,待会下面讲如何通过Domain.List API获取 record_id = xxx , # 换成你的record_id,待会下面讲如何通过Record.List API获取 sub_domain = "xxx" , # 换成你上面创建的子域名 record_line = "默认" , # current_ip = None params . update ( dict ( value = ip )) headers = { "Content-type" : "application/x-www-form-urlencoded" , "Accept" : "text/json" } conn = httplib . HTTPSConnection ( "dnsapi.cn" ) conn . request ( "POST" , "/Record.Ddns" , urllib . urlencode ( params ), headers ) response = conn . getresponse () print response . status , response . reason data = response . read () print data conn . close () return response . status == 200 sock = socket . create_connection (( 'ns1.dnspod.net' , 6666 ), 20 ) ip = sock . recv ( 16 ) sock . close () return ip if __name__ == '__main__' : while True : try : ip = getip () print ip if current_ip != ip : if ddns ( ip ): current_ip = ip except Exception as e :