如何使用身份验证,gui(仅显示下载的文件%)和恢复功能使python urllib2下载文件?

时间:2013-12-11 08:47:54

标签: python-2.7 user-interface progress-bar urllib2 resume-download

到目前为止,我已经这样做了:

import urllib2, base64, os

def dl():
    dwnld="http://xxx.xxx.xxx.xxx:xx/user/file.zip"
    username="user"
    password="pass"
    req=urllib2.Request(dwnld)
    base64str=base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
    req.add_header("Authorization", "Basic %s" % base64str)   
    result=urllib2.urlopen(req)
    with open(os.path.basename(dwnld), "wb") as local_file:
        local_file.write(result.read())
        local_file.close()

dl()

现在我需要一个下载进度窗口(gui)并添加恢复功能。求助。

0 个答案:

没有答案