Beispiel #1
0
    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:
            collect = CollectLinks(
                no_gui=self.no_gui)  # 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.BING:
                links = collect.bing(keyword, add_url)

            elif site_code == Sites.BAIDU:
                links = collect.baidu(keyword, add_url)

            elif site_code == Sites.FLICKR:
                links = collect.flickr(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)

            print('Done {} : {}'.format(site_name, keyword))

        except Exception as e:
            print('Exception {}:{} - {}'.format(site_name, keyword, e))
Beispiel #2
0
    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))