tyw09 发表于 2013-2-17 22:51:54

python版3322自动更新

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#tanyewei@gmail.com
'''
3322自动更新
'''
import urllib
import httplib
import base64
import urllib2
'''
获取自身ip
'''
username='帐号'
password='密码'
domain=域名'
req=urllib2.Request('http://ip.3322.net')
f=urllib2.urlopen(req)
ip=f.read().strip()
#print ip
auth = base64.b64encode(username+ ':'+ password)
headers = {"Authorization": "Basic "+ auth}
conn = httplib.HTTPConnection("members.3322.net")
conn.request("GET","/dyndns/update?hostname=%s&myip=%s&wildcard=OFF&mx=mail.exchanger.ext&backmx=NO&offline=NO"%(domain,ip),body=None,headers=headers)
response = conn.getresponse()
print response.read().strip()加入计划任务定时执行就行啦如:*/5 * * * */usr/bin/python2.7 /root/3322.py >> /tmp/3322.log 2>&1
页: [1]
查看完整版本: python版3322自动更新