diff --git a/collect_links.py b/collect_links.py index 7fbf3f8..55d6b8a 100644 --- a/collect_links.py +++ b/collect_links.py @@ -159,7 +159,7 @@ def google_full(self, keyword, add_url=""): time.sleep(1) links = [] - count = 1 + # count = 1 last_scroll = 0 scroll_patience = 0 @@ -173,8 +173,8 @@ def google_full(self, keyword, add_url=""): if src not in links and src is not None: links.append(src) - print('%d: %s'%(count, src)) - count += 1 + # print('%d: %s'%(count, src)) + # count += 1 except Exception as e: print('[Exception occurred while collecting links from google_full] {}'.format(e)) @@ -191,10 +191,12 @@ def google_full(self, keyword, add_url=""): elem.send_keys(Keys.RIGHT) + links = set(links) + print('Collect links done. Site: {}, Keyword: {}, Total: {}'.format('google_full', keyword, len(links))) self.browser.close() - return set(links) + return links def naver_full(self, keyword, add_url=""): print('[Full Resolution Mode]') @@ -211,7 +213,7 @@ def naver_full(self, keyword, add_url=""): time.sleep(1) links = [] - count = 1 + # count = 1 last_scroll = 0 scroll_patience = 0 @@ -226,8 +228,8 @@ def naver_full(self, keyword, add_url=""): if src not in links and src is not None: links.append(src) - print('%d: %s' % (count, src)) - count += 1 + # print('%d: %s' % (count, src)) + # count += 1 except Exception as e: print('[Exception occurred while collecting links from naver_full] {}'.format(e)) @@ -244,9 +246,12 @@ def naver_full(self, keyword, add_url=""): elem.send_keys(Keys.RIGHT) + links = set(links) + + print('Collect links done. Site: {}, Keyword: {}, Total: {}'.format('naver_full', keyword, len(links))) self.browser.close() - return set(links) + return links if __name__ == '__main__': diff --git a/main.py b/main.py index ec4aa04..9c36e50 100644 --- a/main.py +++ b/main.py @@ -146,7 +146,7 @@ def download_images(self, keyword, links, site_name): print('Downloading {} from {}: {} / {}'.format(keyword, site_name, index + 1, total)) response = requests.get(link, stream=True) ext = self.get_extension_from_link(link) - self.save_image_to_file(response, '{}/{}/{}_{}.{}'.format(self.download_path, keyword, site_name, index, ext)) + self.save_image_to_file(response, '{}/{}/{}_{}.{}'.format(self.download_path, keyword, site_name, str(index).zfill(4), ext)) del response except Exception as e: