xikk 发表于 2015-3-14 21:34:00

DNSPOD 动态解析脚本 for Linux 错误?

脚本如下:
[*]#!/usr/bin/env python
[*]#-*- coding:utf-8 -*-
[*]
[*]import httplib, urllib
[*]import socket
[*]import time
[*]
[*]params = 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 = None
[*]
[*]def 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 == 200
[*]
[*]def getip():
[*]    sock = socket.create_connection(('ns1.dnspod.net', 6666))
[*]    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, e:
[*]            print e
[*]            pass
[*]      time.sleep(30)复制代码

执行之后提示如下

{"status":{"code":"26","message":"Record line invalid","created_at":"2015-03-14 09:49:15"}}

有人说是 record_line 参数不对,你web登陆一下你的域名线路是不是 “默认”

可我DNSPOD里设置的域名也是默认线路,为何执行后会有这个错语 有没人知道啊

xikk 发表于 2015-3-14 21:47:34

"默认" 线路需要 UTF8 编码,要不 API 识别不了

问管方说是编码方式错误 没感觉错啊#-*- coding:utf-8 -*-

欧阳逍遥 发表于 2015-3-15 02:58:00

不会py 文件编码对吗?我也感觉是编码问题,抓包看看。。linux下用nc

xikk 发表于 2015-3-14 21:49:44


欧阳逍遥 发表于 2015-3-14 21:49

不会py 文件编码对吗?我也感觉是编码问题,抓包看看。。linux下用nc




谢谢 果然,,,,真小白啊

mix 发表于 2015-3-14 22:01:05


xikk 发表于 2015-3-14 22:01

谢谢 果然,,,,真小白啊
这是debian还是什么 什么桌面啊
页: [1]
查看完整版本: DNSPOD 动态解析脚本 for Linux 错误?