|
脚本如下:
[ol]#!/usr/bin/env python#-*- coding:utf-8 -*-import httplib, urllibimport socketimport timeparams = dict( login_email="email", # replace with your email login_password="password", # replace with your password format="json", domain_id=100, # replace with your domain_od, can get it by API Domain.List record_id=100, # replace with your record_id, can get it by API Record.List sub_domain="www", # replace with your sub_domain record_line="默认",)current_ip = Nonedef ddns(ip): 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 == 200def getip(): sock = socket.create_connection(('ns1.dnspod.net', 6666)) ip = sock.recv(16) sock.close() return ipif __name__ == '__main__': while True: try: ip = getip() print ip if current_ip != ip: if ddns(ip): current_ip = ip except Exception, e: print e pass time.sleep(30)[/ol]复制代码
执行之后提示如下
{"status":{"code":"26","message":"Record line invalid","created_at":"2015-03-14 09:49:15"}}
有人说是 record_line 参数不对,你web登陆一下你的域名线路是不是 “默认”
可我DNSPOD里设置的域名也是默认线路,为何执行后会有这个错语 有没人知道啊
|
|