希网3322域名更新脚本(Python)
2015-05-09 12:18
351 查看
import re,urllib2 class DDNS: def getip(self): try: myip = self.visit("http://www.whereismyip.com/") except: try: myip = self.visit("http://www.ip138.com/") except: myip = None return myip def visit(self,url): opener = urllib2.urlopen(url) if url == opener.geturl(): str = opener.read() return re.search('\d+\.\d+\.\d+\.\d+',str).group(0) def updateIP(self): ip=self.getip() if(ip==None): break auth= urllib2.HTTPPasswordMgrWithDefaultRealm() url = "http://members.3322.net/dyndns/update?system=dyndns&myip="+ip+"&hostname=test.3322.org" auth.add_password(None, url, user='test',passwd='test123') handler = urllib2.HTTPBasicAuthHandler(auth) opener = urllib2.build_opener(handler) urllib2.install_opener(opener) f=urllib2.urlopen(url) print f.read() if __name__ == '__main__': DNS = DDNS() DNS.updateIP()
相关文章推荐
- Python 实现数据库(SQL)更新脚本的生成方法
- 写了个Python脚本 帮助更新Android工程里面的gradle, android和依赖版本
- 更新3322域名的ip地址
- Python脚本实现值更新事件赋值过程记录日志监控
- python实现动态更新远程机器列表的SSH登录脚本
- C++调用Python脚本碰到的问题及解决方法【更新中】
- dnspod批量更新添加激活DNS解析【python脚本】
- 【不断更新】python脚本常用的函数!
- RB750 Ros4.16动态域名更新脚本,发送IP地址到指定Email
- Python脚本,自动更新host,添加or更新本机hosts
- 【选课脚本】用Python网页爬虫来进行选(qiang)课 (更新至v1.0.7)
- DNSPOD API 域名的动态IP的更新脚本
- 更新hosts文件的python脚本
- 【Python】python更新数据库脚本两种方法
- python脚本实现批量更新数据库中字段值
- Python自动更新脚本
- 更新hosts的python脚本
- python脚本实现分析dns日志并对受访域名排行
- python更新数据库脚本三种方法
- 用Python写的简单脚本更新本地hosts