python下载脚本
#/usr/bin/env python
#coding:UTF-8
import time
import os,sys
import urllib2
url = 'http://downloaduat.laocaibao.com/front/front.war'
tm = time.strftime('%Y%m%d',time.localtime(time.time()))
warname = 'front.war'
downdir = '/home/deployer/update/'
def downloadbag():
print '''
开始下载新的文件包front.war
下载地址:http://downloaduat.laocaibao.com/front/front.war
'''
if (not os.path.exists(downdir+tm)):
os.mkdir(downdir+tm)
os.chdir(downdir+tm)
f = urllib2.urlopen(url)
data = f.read()
with open("front.war", "wb") as code:
code.write(data)
downloadbag()