473,385 Members | 1,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how?python urllib2 download file with auth, gui (show file %) and resume capability?

I need a download progress window (gui) and resume capability added to it.

So far I have done this:

Expand|Select|Wrap|Line Numbers
  1. import urllib2, base64, os
  2.  
  3. def dl():
  4.     dwnld="http://xxx.xxx.xxx.xxx:xx/user/file.zip"
  5.     username="user"
  6.     password="pass"
  7.     req=urllib2.Request(dwnld)
  8.     base64str=base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
  9.     req.add_header("Authorization", "Basic %s" % base64str)   
  10.     result=urllib2.urlopen(req)
  11.     with open(os.path.basename(dwnld), "wb") as local_file:
  12.         local_file.write(result.read())
  13.         local_file.close()
  14.  
  15. dl()
  16.  
Help please.
Attached Files
File Type: zip dwnldr.zip (434 Bytes, 61 views)
Dec 11 '13 #1
0 1377

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: dspohn | last post by:
I am designing a document management system (DMS). The files are stored in a directory on the webserver. The filenames for the documents are stored in a MySQL database. The DMS will track...
3
by: Andrew Henry | last post by:
I'm trying to create an ASP page which, when it loads runs the ASP code first then prompts the user to download a text file. I know the answer might be obvious to some of you, but I've sone...
7
by: Davy | last post by:
Hi all, A read-only data file is read in a C/C++ program. And now I use stdio function such as fopen() to fread() to operate the file. The content of the data file is constant. How to build...
6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
6
by: Alejandro Dubrovsky | last post by:
I see from googling around that this is a popular topic, but I haven't seen anyone saying "ah, yes, that works", so here it goes. How does one connect through a proxy which requires basic...
4
by: Gary | last post by:
Hi I'm using client-side JavaScript to set window.location.href to an ASP.NET page that outputs an audio file; the user is prompted for the download location. I would also like to download an...
17
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
2
by: NOSPAM plz | last post by:
Hey, My problem is, is it possible to download parts of a file while. i think is it is called threading My code thats download the whole webpage, and stunds the app while is is downloading: ...
1
by: ajash.pv | last post by:
i wana the source code of down load more than one file at a time("filesave as" show only one time and i wana to store more than one file at same destination) any way for this.... Dim file...
9
by: flebber | last post by:
I was working at creating a simple program that would read the content of a playlist file( in this case *.k3b") and write it out . the compressed "*.k3b" file has two file and the one I was trying...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.