Skip to content

Commit

Permalink
Merge pull request YoongiKim#19 from hajunho/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
YoongiKim authored Jun 25, 2020
2 parents 1f2a9d0 + 4396a46 commit 45c9911
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
Binary file modified chromedriver/chromedriver_linux
Binary file not shown.
Binary file modified chromedriver/chromedriver_mac
Binary file not shown.
Binary file modified chromedriver/chromedriver_win.exe
Binary file not shown.
7 changes: 6 additions & 1 deletion collect_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import platform
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
import os.path as osp


Expand All @@ -45,7 +46,11 @@ def __init__(self):
if not osp.exists(executable):
raise FileNotFoundError('Chromedriver file should be placed at {}'.format(executable))

self.browser = webdriver.Chrome(executable)
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
self.browser = webdriver.Chrome(executable, chrome_options=chrome_options)

browser_version = 'Failed to detect version'
chromedriver_version = 'Failed to detect version'
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def base64_to_object(src):
return data

def download_images(self, keyword, links, site_name):
self.make_dir('{}/{}'.format(self.download_path, keyword))
self.make_dir('{}/{}'.format(self.download_path, keyword.replace('"', '')))
total = len(links)

for index, link in enumerate(links):
Expand All @@ -177,7 +177,7 @@ def download_images(self, keyword, links, site_name):
ext = self.get_extension_from_link(link)
is_base64 = False

no_ext_path = '{}/{}/{}_{}'.format(self.download_path, keyword, site_name, str(index).zfill(4))
no_ext_path = '{}/{}/{}_{}'.format(self.download_path.replace('"', ''), keyword, site_name, str(index).zfill(4))
path = no_ext_path + '.' + ext
self.save_object_to_file(response, path, is_base64=is_base64)

Expand Down

0 comments on commit 45c9911

Please sign in to comment.