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()python

相關文章
相關標籤/搜索