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 6373399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:21:34+00:00 2026-05-25T01:21:34+00:00

In Python , If I am using wget to download a file using os.system(wget

  • 0

In Python , If I am using “wget” to download a file using os.system(“wget ), it shows on the screen like:

 Resolving...

 Connecting to ...

 HTTP request sent, awaiting response...

 100%[====================================================================================================================================================================>] 19,535,176  8.10M/s   in 2.3s 

etc on the screen.

What can I do to save this output in some file rather than showing it on the screen ?

Currently I am running the command as follows:

theurl = "< file location >"
downloadCmd = "wget "+theurl
os.system(downloadCmd)
  • 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-05-25T01:21:35+00:00Added an answer on May 25, 2026 at 1:21 am

    To answer your direct question, and as others have mentioned, you should strongly consider using the subprocess module. Here’s an example:

    from subprocess import Popen, PIPE, STDOUT
    
    wget = Popen(['/usr/bin/wget', theurl], stdout=PIPE, stderr=STDOUT)
    stdout, nothing = wget.communicate()    
    
    with open('wget.log', 'w') as wgetlog:
        wgetlog.write(stdout)
    

    But, no need to call out to the system to download a file, let python do the heavy lifting for you.

    Using urllib,

    try: 
        # python 2.x
        from urllib import urlretrieve
    except ImportError:
        # python 3.x
        from urllib.request import urlretrieve
    
    urlretrieve(theurl, local_filename)
    

    Or urllib2,

    import urllib2
    
    response = urllib2.urlopen(theurl)
    with open(local_filename, 'w') as dl:
        dl.write(response.read())
    

    local_filename is the destination path of your choosing. It is sometimes possible to determine this value automatically, but the approach depends on your circumstance.

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

Sidebar

Related Questions

I'd like to call a function in python using a dictionary with matching key-value
I am learning Python using Dive Into Python 3 book. I like it, but
I am programming a software in Python to download HTTP PDF from a database.
When I compiled Python using PCBuild\build.bat I discovered that several Python external projects like
I started learning Python using the IronPython implementation. I'd like to do some web
When load matrices from mat file in python using scipy.io , it makes dictionary
I'm writing an application in python using CherryPy and Jinja as the template system.
I was learning python using the tutorial that comes with the standard python installation.
I'm currently learning Python using Zelle's Introductory text, and I'm trying to recreate one
I'm using the following method to send mail from Python using SMTP. Is it

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.