Skip to content

Instantly share code, notes, and snippets.

@theonlypwner
Created January 30, 2016 02:53
Show Gist options
  • Save theonlypwner/b737eb87a5630006687c to your computer and use it in GitHub Desktop.
Save theonlypwner/b737eb87a5630006687c to your computer and use it in GitHub Desktop.
Multiple File Downloader
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