# -*- coding: cp936 -*-
'''
Created on 2011-8-4
@author: flyfox
@function:实现根据url下载
'''
import urllib,datetime,sys
def download(url):
starttime = datetime.datetime.now()
print 'download start time is %s'% starttime
urllib.urlretrieve(url,'test.html') #开始下载,test.exe为下载后保存的文件名
endtime = datetime.datetime.now()
print 'download end time is %s'% endtime
print 'you download the file use time %s s' % (endtime - starttime).seconds
if __name__ == '__main__':
if len(sys.argv) == 2:
try:
download(sys.argv[1])
except IOError:
print 'url not found'
else:
download('http://www.python.org/')