(keywords, engine="Google", max_number=10000,
                     face_only=False, safe_mode=False, proxy=None, 
                     proxy_type="http", quiet=False, browser="phantomjs", image_type=None, color=None)
return image_urls[0:output_num]
Scrape image urls of keywords from Google Image Search
    :param keywords: keywords you want to search
    :param engine: search engine used to search images
    :param max_number: limit the max number of image urls the function output, equal or less than 0 for unlimited
    :param face_only: image type set to face only, provided by Google
    :param safe_mode: switch for safe mode of Google Search
    :param proxy: proxy address, example: socks5 127.0.0.1:1080
    :param proxy_type: socks5, http
    :param browser: browser to use when crawl image urls from Google & Bing 
    :return: list of scraped image urls
Scrape image urls of keywords from Google Image Search
    :param keywords: keywords you want to search
    :param engine: search engine used to search images
    :param max_number: limit the max number of image urls the function output, equal or less than 0 for unlimited
    :param face_only: image type set to face only, provided by Google
    :param safe_mode: switch for safe mode of Google Search
    :param proxy: proxy address, example: socks5 127.0.0.1:1080
    :param proxy_type: socks5, http
    :param browser: browser to use when crawl image urls from Google & Bing 
    :return: list of scraped image urls
Scrape image urls of keywords from Google Image Search : param keywords : keywords you want to search : param engine : search engine used to search images : param max_number : limit the max number of image urls the function output equal or less than 0 for unlimited : param face_only : image type set to face only provided by Google : param safe_mode : switch for safe mode of Google Search : param proxy : proxy address example : socks5 127 . 0 . 0 . 1 : 1080 : param proxy_type : socks5 http : param browser : browser to use when crawl image urls from Google & Bing : return : list of scraped image urls
def crawl_image_urls(keywords, engine="Google", max_number=10000,
                     face_only=False, safe_mode=False, proxy=None, 
                     proxy_type="http", quiet=False, browser="phantomjs", image_type=None, color=None):
    """
    Scrape image urls of keywords from Google Image Search
    :param keywords: keywords you want to search
    :param engine: search engine used to search images
    :param max_number: limit the max number of image urls the function output, equal or less than 0 for unlimited
    :param face_only: image type set to face only, provided by Google
    :param safe_mode: switch for safe mode of Google Search
    :param proxy: proxy address, example: socks5 127.0.0.1:1080
    :param proxy_type: socks5, http
    :param browser: browser to use when crawl image urls from Google & Bing 
    :return: list of scraped image urls
    """

    my_print("\nScraping From {0} Image Search ...\n".format(engine), quiet)
    my_print("Keywords:  " + keywords, quiet)
    if max_number <= 0:
        my_print("Number:  No limit", quiet)
        max_number = 10000
    else:
        my_print("Number:  {}".format(max_number), quiet)
    my_print("Face Only:  {}".format(str(face_only)), quiet)
    my_print("Safe Mode:  {}".format(str(safe_mode)), quiet)

    if engine == "Google":
        query_url = google_gen_query_url(keywords, face_only, safe_mode, image_type, color)
    elif engine == "Bing":
        query_url = bing_gen_query_url(keywords, face_only, safe_mode, image_type, color)
    elif engine == "Baidu":
        query_url = baidu_gen_query_url(keywords, face_only, safe_mode, color)
    else:
        return

    my_print("Query URL:  " + query_url, quiet)

    if engine != "Baidu":
        browser = str.lower(browser)
        if "chrome" in browser:
            chrome_path = shutil.which("chromedriver")
            chrome_path = "./bin/chromedriver" if chrome_path is None else chrome_path
            chrome_options = webdriver.ChromeOptions()
            if "headless" in browser:
                chrome_options.add_argument("headless")
            if proxy is not None and proxy_type is not None:
                chrome_options.add_argument("--proxy-server={}://{}".format(proxy_type, proxy))
            driver = webdriver.Chrome(chrome_path, chrome_options=chrome_options)
        else:
            phantomjs_path = shutil.which("phantomjs")
            phantomjs_path = "./bin/phantomjs" if phantomjs_path is None else phantomjs_path
            phantomjs_args = []
            if proxy is not None and proxy_type is not None:
                phantomjs_args += [
                    "--proxy=" + proxy,
                    "--proxy-type=" + proxy_type,
                ]
            driver = webdriver.PhantomJS(executable_path=phantomjs_path,
                                        service_args=phantomjs_args, desired_capabilities=dcap)

    if engine == "Google":
        driver.set_window_size(1920, 1080)
        driver.get(query_url)
        image_urls = google_image_url_from_webpage(driver, max_number, quiet)
    elif engine == "Bing":
        driver.set_window_size(1920, 1080)
        driver.get(query_url)
        image_urls = bing_image_url_from_webpage(driver)
    else:   # Baidu
        # driver.set_window_size(10000, 7500)
        # driver.get(query_url)
        # image_urls = baidu_image_url_from_webpage(driver)
        image_urls = baidu_get_image_url_using_api(keywords, max_number=max_number, face_only=face_only,
                                                   proxy=proxy, proxy_type=proxy_type)
    if engine != "Baidu":
        driver.close()

    if max_number > len(image_urls):
        output_num = len(image_urls)
    else:
        output_num = max_number

    my_print("\n== {0} out of {1} crawled images urls will be used.\n".format(
        output_num, len(image_urls)), quiet)

    return image_urls[0:output_num]
def crawl_image_urls ( keywords , engine = "Google" , max_number = 10000 , face_only = False , safe_mode = False , proxy = None , proxy_type = "http" , quiet = False , browser = "phantomjs" , image_type = None , color = None ) : my_print ( "\nScraping From {0} Image Search ...\n" . format ( engine ) , quiet ) my_print ( "Keywords:  " + keywords , quiet ) if max_number <= 0 : my_print ( "Number:  No limit" , quiet ) max_number = 10000 else : my_print ( "Number:  {}" . format ( max_number ) , quiet ) my_print ( "Face Only:  {}" . format ( str ( face_only ) ) , quiet ) my_print ( "Safe Mode:  {}" . format ( str ( safe_mode ) ) , quiet ) if engine == "Google" : query_url = google_gen_query_url ( keywords , face_only , safe_mode , image_type , color ) elif engine == "Bing" : query_url = bing_gen_query_url ( keywords , face_only , safe_mode , image_type , color ) elif engine == "Baidu" : query_url = baidu_gen_query_url ( keywords , face_only , safe_mode , color ) else : return my_print ( "Query URL:  " + query_url , quiet ) if engine != "Baidu" : browser = str . lower ( browser ) if "chrome" in browser : chrome_path = shutil . which ( "chromedriver" ) chrome_path = "./bin/chromedriver" if chrome_path is None else chrome_path chrome_options = webdriver . ChromeOptions ( ) if "headless" in browser : chrome_options . add_argument ( "headless" ) if proxy is not None and proxy_type is not None : chrome_options . add_argument ( "--proxy-server={}://{}" . format ( proxy_type , proxy ) ) driver = webdriver . Chrome ( chrome_path , chrome_options = chrome_options ) else : phantomjs_path = shutil . which ( "phantomjs" ) phantomjs_path = "./bin/phantomjs" if phantomjs_path is None else phantomjs_path phantomjs_args = [ ] if proxy is not None and proxy_type is not None : phantomjs_args += [ "--proxy=" + proxy , "--proxy-type=" + proxy_type , ] driver = webdriver . PhantomJS ( executable_path = phantomjs_path , service_args = phantomjs_args , desired_capabilities = dcap ) if engine == "Google" : driver . set_window_size ( 1920 , 1080 ) driver . get ( query_url ) image_urls = google_image_url_from_webpage ( driver , max_number , quiet ) elif engine == "Bing" : driver . set_window_size ( 1920 , 1080 ) driver . get ( query_url ) image_urls = bing_image_url_from_webpage ( driver ) else : # Baidu # driver.set_window_size(10000, 7500) # driver.get(query_url) # image_urls = baidu_image_url_from_webpage(driver) image_urls = baidu_get_image_url_using_api ( keywords , max_number = max_number , face_only = face_only , proxy = proxy , proxy_type = proxy_type ) if engine != "Baidu" : driver . close ( ) if max_number > len ( image_urls ) : output_num = len ( image_urls ) else : output_num = max_number my_print ( "\n== {0} out of {1} crawled images urls will be used.\n" . format ( output_num , len ( image_urls ) ) , quiet ) return image_urls [ 0 : output_num ]