diff --git a/README.md b/README.md index 743cbaa..7a06a2c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,12 @@ A Python script to scrape wallpapers from https://4kwallpapers.com/. ## Usage -The program takes a single command line argument, namely the root folder of -whre you want all the pictures to go. It'll create sub-folders for all the -categories, and download all pictures in one go. Yes, this can take a while -(15m in my case, with a fast internet connection). +The program takes one or more arguments. The first argument is the path to the +download directory; this is where the pictures will end up. Each category +creates a subdirectory for itself. + +Any arguments following the path correspond to category names. This allows you +to only download certain categories. + +Do note that a full download can take a while: upwards of 15 minutes on a fast +internet connection. diff --git a/scraper.py b/scraper.py index 2439dc6..2b0fb8d 100644 --- a/scraper.py +++ b/scraper.py @@ -68,9 +68,10 @@ class Scraper(PageHandler): def images(self): return sum([cat.images for cat in self.categories], []) - def download(self, dir_path): + def download(self, dir_path, cats=None): for cat in self.categories: - cat.download(dir_path) + if cats and cat.name in cats: + cat.download(dir_path) class Category(PageHandler): @@ -155,4 +156,12 @@ class Image(PageHandler): if __name__ == "__main__": scraper = Scraper() - scraper.download(sys.argv[1]) + + if len(sys.argv) == 1: + print("No path provided.") + + elif len(sys.argv) == 2: + scraper.download(sys.argv[1]) + + else: + scraper.download(sys.argv[1], sys.argv[2:])