python urllib从远程服务器下载文件到本地

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/bin/env python
#-*-coding:utf-8-*-'
#Filename:download_file.py

import sys,os
import urllib

def urlcallback(a,b,c):
    """
        call back function
        a,已下载的数据块
        b,数据块的大小
        c,远程文件的大小
    """
    print "callback"
    prec=100.0*a*b/c
    if 100 < prec:
        prec=100
    print "%.2f%%"%(prec,)

def main(argv):
    """
        main
    """
    print "start..."
    urllib.urlretrieve("<a href="http://jaist.dl.sourceforge.net/project/pydev/pydev/Pydev%201.6.3/org.python.pydev.feature-1.6.3.2010100513.zip">http://jaist.dl.sourceforge.net/project/pydev/pydev/Pydev%201.6.3/org.python.pydev.feature-1.6.3.2010100513.zip"\\
                      ,"/tmp/python.pydev.zip"\\
                      ,urlcallback)
    print "end..."

if __name__=="__main__":
    main(sys.argv[1:])