Created
January 30, 2016 02:53
-
-
Save theonlypwner/b737eb87a5630006687c to your computer and use it in GitHub Desktop.
Multiple File Downloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
FILES_TO_DOWNLOAD = """ | |
google.com | |
example.com | |
""" | |
for line in FILES_TO_DOWNLOAD.splitlines(): | |
if not line: | |
continue | |
# default to HTTP | |
if line.find('://') == -1: | |
line = 'http://' + line | |
filename = line[line.rfind('/')+1:] # TODO: use better detection for the file name | |
req = urllib.request.urlopen(line) | |
with open(filename, 'wb') as f: | |
f.write(req.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment