Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7875647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:01:08+00:00 2026-06-03T03:01:08+00:00

I have multiple URLs that returns zip files. Most of the files, I’m able

  • 0

I have multiple URLs that returns zip files. Most of the files, I’m able to download using urllib2 library as follows:

request = urllib2.urlopen(url)
zip_file = request.read()

The problem I’m having is that one of the files is 35Mb in size (zipped) and I’m never able to finish downloading it using this library. I’m able to download it using wget and the browser normally.

I have tried downloading the file in chuncks like this:

request = urllib2.urlopen(url)
buffers = []
while True:
    buffer = request.read(8192)
    if buffer:
        buffers.append(buffer)
    else:
        break
final_file = ''.join(buffers)

But this also does not finish the download. No error is raised, so it’s hard to debug what is happening. Unfortunately, I can’t post an example of the url / file here.

Any suggestions / advices?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:01:10+00:00Added an answer on June 3, 2026 at 3:01 am

    This is copy / paste from my application which downloads it’s own update installer. It reads the file in blocks and immediately saves the blocks in output file on the disk.

    def DownloadThreadFunc(self):
        try:
            url = self.lines[1]
            data = None
            req = urllib2.Request(url, data, {})
            handle = urllib2.urlopen(req)
    
            self.size = int(handle.info()["Content-Length"])
            self.actualSize = 0
            name = path.join(DIR_UPDATES, url.split("/")[-1])
            blocksize = 64*1024
    
            fo = open(name, "wb")
            while not self.terminate:
                block = handle.read(blocksize)
                self.actualSize += len(block)
                if len(block) == 0:
                    break
                fo.write(block)
            fo.close()
        except (urllib2.URLError, socket.timeout), e:
            try:
                fo.close()
            except:
                pass
            error("Download failed.", unicode(e))  
    

    I use self.size and self.actualSize to show the download progress in GUI thread and self.terminate to cancel the download from the GUI button if needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple URLs for users to download. The download should be triggered after
In one of my Controllers, I have multiple URLs that will ultimately render in
I have multiple objects that I'd like to be accessible via human-readable URLs, so
I have multiple calls to methods in a 3rd party library. These methods have
Currently, I have URLs that look like this: http://www.example.com/user/create http://www.example.com/user/edit/1 But now, I have
I have a normalized database that stores locations of files on the internet. A
I have one application that I sold to multiple clients. Each client has his
I have to scrap a web site where i need to fetch multiple URLs
I have been using the Zend_Service_Amazon_S3 library to access Amazon S3, but have been
I have a table that stores image URLs by product id and am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.