• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 555
  • Last Modified:

Download files using python?

Is there a way to have python download and save files from the internet, if I can give it the url?  I would need the steps necessary for both getting the file and saving it somewhere.

Thanks in advance!
0
jonnyz0109
Asked:
jonnyz0109
1 Solution
 
RichieHindleCommented:
Here's how to do it:

import urllib2
input = urllib2.urlopen('http://google.com/')
output = open('google.html', 'wb')
output.write(input.read())

That will download and save an HTML page - the same script will work for a binary file as well.
0
 
jonnyz0109Author Commented:
Excellent, thanks!  :o)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now