Accept multiple threads as input arguments

master
Sven Slootweg 13 years ago
parent 7d578cdea3
commit df175d7715

6
4c

@ -7,7 +7,7 @@ import re, urllib, urllib2, argparse, os
parser = argparse.ArgumentParser(description='Downloads all full-size images in an arbitrary 4chan thread.') parser = argparse.ArgumentParser(description='Downloads all full-size images in an arbitrary 4chan thread.')
parser.add_argument('urllist', metavar='url', type=str, nargs=1, parser.add_argument('urllist', metavar='url', type=str, nargs='+',
help='the URL of the thread') help='the URL of the thread')
parser.add_argument('-n', '--newdir', dest='newdir', action='store_true', parser.add_argument('-n', '--newdir', dest='newdir', action='store_true',
help='create a new directory for this thread in the current directory') help='create a new directory for this thread in the current directory')
@ -18,7 +18,9 @@ args = parser.parse_args()
options = vars(args) options = vars(args)
regex = 'href="(\/\/images\.4chan\.org\/b\/src\/[0-9]+\.[a-z]+)"' regex = 'href="(\/\/images\.4chan\.org\/b\/src\/[0-9]+\.[a-z]+)"'
url = options['urllist'][0]
for url in options['urllist']:
print "Thread URL: %s" % url
try: try:
page = urllib2.urlopen(url).read() page = urllib2.urlopen(url).read()

Loading…
Cancel
Save