花生壳动态IP域名解析之python自动提交公网IP
2015-05-22 17:12
375 查看
#!/usr/bin/env python import re import os import time import random ip_current = '' while True: myip = re.findall(r'\d+\.\d+\.\d+\.\d+',os.popen('curl -s http://ddns.oray.com/checkip').read()) print time.strftime("%Y-%m-%d %H:%M:%S") print 'current public ip is', myip if myip and myip != ip_current: print 'current public ip has changed' ip_current = myip webinfo = os.popen('curl -s http://用户名:密码@ddns.oray.com/ph/update?hostname=域名&myip=').read() print 'commit info:', webinfo if 'good' in webinfo: print 'result: commit ok' elif 'nochg' in webinfo: print 'result: no change' else: print 'result: commit failure' else: print 'current public ip has not changed' print '---' time.sleep(random.randint(300,600))
最后编辑开机启动项文件/etc/rc.local,添加路径:/home/shenwenkai/activeip.py
相关文章推荐
- 【树莓派】python3脚本 自动上报ip到万网域名解析
- 跨网段实现DHCP动态IP的自动分配(DHCP中继)
- 关于如何建立网站 和 花生壳映射动态ip
- python 动态加载 和 自动测试 探讨 (一)
- 关于花生壳动态ip映射的一点唠叨
- [Python爬虫] 使用urllib2库检测代理ip是否可用,并使用代理提交GET、POST请求
- Python3 BeautifulSoup爬虫 ZOJ自动提交
- python实现自动获取IP并发到邮箱
- python 自动抓取代理ip
- 发邮件自动回复本机IP——python版本
- python+selenium 自动填写表单并提交
- python---项目5-TCP单线程扫描器与TCP多线程TCP扫描器(公网/局域网IP与域名)、Nmap扫描器(局域网/公网)
- 使用python写的如何自动提交和抓取网页
- Python实现的百度站长自动URL提交小工具
- 使用Python脚本自动修改Windows的IP、网关和DNS设置
- python获取绑定的IP,并动态指定出口IP
- 远程桌面+花生壳控制adsl动态ip用户的电脑
- python 例子: 实现动态加载类,并自动执行它定义的函数