[DDNS] No-IP更新DDNS记录接口

2023-06-25  本文已影响0人  Cocoonshu

接口

参数示例

Python验证

import httplib2
import base64

def update(noipAccount, noipPassword, updateDomain, updatingAddress):
        """update IP Address to No-IP"""
        auth = base64.b64encode((noipAccount + ':' + noipPassword).encode('utf-8')).decode('utf-8')
        headers = {
                'Authorization' : 'Basic ' + auth,
                'User-Agent' : 'ddnslib.UpdateNoIP/1.0 Cocoonshu'
        }
        url = '/nic/update?hostname=' + updateDomain + '&myip=' + updatingAddress
        host = 'dynupdate.no-ip.com'

        http = httplib2.Http()
        response = http.request(uri='https://' + host + url, method='GET', headers=headers)
        return response

if __name__ == '__main__':
        domain='cocoonshu.ddns.net'
        address='185.199.110.153'
        result = update(
                noipAccount='Cocoonshu',
                noipPassword='123456',
                updateDomain=domain,
                updatingAddress=address
        )
        print(
                'Updating ' + domain + '(' + address + ') to No-IP: '
                + str(result[0].status) + '->' + result[0].reason + "::" + result[1].decode()
        )
上一篇 下一篇

猜你喜欢

热点阅读