def download_from_site(self, keyword, site_code): site_name = Sites.get_text(site_code) add_url = Sites.get_face_url(site_code) if self.face else "" collect = CollectLinks() # initialize chrome driver try: print('Collecting links... {} from {}'.format(keyword, site_name)) if site_code == Sites.GOOGLE: links = collect.google(keyword, add_url) elif site_code == Sites.NAVER: links = collect.naver(keyword, add_url) elif site_code == Sites.GOOGLE_FULL: links = collect.google_full(keyword, add_url) elif site_code == Sites.NAVER_FULL: links = collect.naver_full(keyword, add_url) else: print('Invalid Site Code') links = [] print( 'Downloading images from collected links... {} from {}'.format( keyword, site_name)) self.download_images(keyword, links, site_name) print('Done {} : {}'.format(site_name, keyword)) except Exception as e: print('Exception {}:{} - {}'.format(site_name, keyword, e))
def download_from_site(self, keyword, site_code): site_name = Sites.get_text(site_code) add_url = Sites.get_face_url(site_code) if self.face else "" try: proxy = None if self.proxy_list: proxy = random.choice(self.proxy_list) collect = CollectLinks(no_gui=self.no_gui, proxy=proxy) # initialize chrome driver except Exception as e: print('Error occurred while initializing chromedriver - {}'.format( e)) return try: print('Collecting links... {} from {}'.format(keyword, site_name)) if site_code == Sites.GOOGLE: links = collect.google(keyword, add_url) elif site_code == Sites.NAVER: links = collect.naver(keyword, add_url) elif site_code == Sites.GOOGLE_FULL: links = collect.google_full(keyword, add_url) elif site_code == Sites.NAVER_FULL: links = collect.naver_full(keyword, add_url) else: print('Invalid Site Code') links = [] print( 'Downloading images from collected links... {} from {}'.format( keyword, site_name)) self.download_images(keyword, links, site_name, max_count=self.limit) Path('{}/{}/{}_done'.format(self.download_path, keyword.replace('"', ''), site_name)).touch() print('Done {} : {}'.format(site_name, keyword)) except Exception as e: print('Exception {}:{} - {}'.format(site_name, keyword, e))
def download_from_site(self, keyword, region, site_code): site_name = Sites.get_text(site_code) add_url = Sites.get_face_url(site_code) if self.face else "" try: collect = CollectLinks( no_gui=self.no_gui, no_driver=self.no_driver) # initialize chrome driver except Exception as e: print("Error occurred while initializing chromedriver - {}".format( e)) return try: print("Collecting links... {} from {}".format(keyword, site_name)) if site_code == Sites.GOOGLE: links = collect.google(keyword, region, add_url) elif site_code == Sites.GOOGLE_FULL: links = collect.google_full(keyword, region, add_url, self.limit) else: print("Invalid Site Code") links = [] print("Google Links:", len(links)) links = links + collect.pinterest(keyword, region, add_url, self.limit) print("Total Links:", len(links)) print("Downloading images from {} collected links... {} from {}". format(len(links), keyword, site_name)) self.download_images(keyword, links, site_name, max_count=len(links)) print("Done {} : {}".format(site_name, keyword)) except Exception as e: print("Exception {}:{} - {}".format(site_name, keyword, e))
def downlaod_from_site(self, keyword, site_code): site_name = SearchEngines.get_text(site_code) add_url = SearchEngines.get_face_url(site_code) try: collect = CollectLinks() # initialize Chrome driver except Exception as excep: print('Unable to initialize Chrome driver - {}'.format(excep)) return try: print('Collecting links...{} from {}'.format(keyword, site_name)) if site_code == SearchEngines.Google: links = collect.google(keyword, add_url) elif site_code == SearchEngines.Bing: links = collect.bing(keyword, add_url) elif site_code == SearchEngines.Google_HDR: links = collect.google_full(keyword, add_url) elif site_code == SearchEngines.Bing_HDR: links = collect.bing_full(keyword, add_url) else: print('Invalid Site Code') links = [] print( 'Downloading images from Collected links...{} from {}'.format( keyword, site_name)) self.download_images(keyword, links, site_name) print('Done {} : {}'.format(site_name, keyword)) except Exception as excep: print('Exception {}:{} - {}'.format(site_name, keyword, excep))
def download_from_site(self, keyword, site_code): site_name = Sites.get_text(site_code) add_url = Sites.get_face_url(site_code) if self.face else "" collect = CollectLinks() # initialize chrome driver try: dirname = '{}/{}'.format(self.download_path, keyword) if os.path.exists(os.path.join(os.getcwd(), dirname)) and self.skip: print('Skipping already existing directory {}'.format(dirname)) return print('Collecting links... {} from {}'.format(keyword, site_name)) if site_code == Sites.GOOGLE: links = collect.google(keyword, add_url) elif site_code == Sites.NAVER: links = collect.naver(keyword, add_url) elif site_code == Sites.GOOGLE_FULL: links = collect.google_full(keyword, add_url) elif site_code == Sites.NAVER_FULL: links = collect.naver_full(keyword, add_url) else: print('Invalid Site Code') links = [] print('Downloading images from collected links... {} from {}'.format(keyword, site_name)) self.download_images(keyword, links, site_name) print('Done {} : {}'.format(site_name, keyword)) except Exception as e: print('Exception {}:{} - {}'.format(site_name, keyword, e))