Skip to content

Instantly share code, notes, and snippets.

@bkrepo
Created January 25, 2017 02:10
Show Gist options
  • Save bkrepo/fded9f44eeca464fa916b8bdbe59a299 to your computer and use it in GitHub Desktop.
Save bkrepo/fded9f44eeca464fa916b8bdbe59a299 to your computer and use it in GitHub Desktop.
Get all files in URL
#!/usr/bin/python
import re
import os
import sys
import urllib2
if len(sys.argv) != 2:
print "Usage: imgget.py <Download URL>"
sys.exit(1)
url = sys.argv[1]
req = urllib2.Request(url)
res = urllib2.urlopen(req)
p = re.compile(r'<a href=\"(.+)\">(.+)<\/a>')
for line in res:
m = p.search(line)
if m:
file_name = m.group(1)
fn, ext = os.path.splitext(file_name)
if ext == '.zip' or ext == '.xz' or ext == '.gz':
os.system('wget '+ url + file_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment