Created
January 25, 2017 02:10
-
-
Save bkrepo/fded9f44eeca464fa916b8bdbe59a299 to your computer and use it in GitHub Desktop.
Get all files in URL
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
#!/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