Google image download with python cannot download images

后端 未结 2 771
北荒
北荒 2020-12-30 12:13

I\'m using google_images_download library to download top 20 images for a keyword. It\'s worked perfectly when I\'m using it last days. Code is as follows.

相关标签:
2条回答
  • 2020-12-30 12:19

    There has been some changes on Google end (how they respond to the request) which results in this issue. Joeclinton1 on github has done some modifications to the original repo which provides a temporary fix.

    You can find the updated repo here: https://github.com/Joeclinton1/google-images-download.git . The solution is in patch-1 branch if I'm not mistaken.

    1. First uninstall the current version of google_images_download.

    2. Then manually install Joeclinton1's repo by:

    git clone https://github.com/Joeclinton1/google-images-download.git
    cd google-images-download && sudo python setup.py install #no need for 'sudo' on windows Anaconda environment
    

    or to install it with pip

    pip install git+https://github.com/Joeclinton1/google-images-download.git
    

    This should solve the problem. Note that currently this repo only supports upto 100 images.

    0 讨论(0)
  • 2020-12-30 12:24

    I faced the same issue with google-image-download, which used to work perfect earlier! I have an alternative that I would like to suggest, which should solve the problem.

    Solution: Instead of using google-image-download for Python, use bing-image-downloader, that downloads from Bing! search engine.

    Steps:

    Step 1: Install the library by using: pip install bing-image-downloader

    Step 2:

    from bing_image_downloader import downloader
    downloader.download(query_string, limit=100,  output_dir='dataset', 
    adult_filter_off=True, force_replace=False, timeout=60)
    

    That's it! All you would need to do is to add your image topic to the query_string.

    Note:

    Parameters that you can further tweak:

    query_string : String to be searched.

    limit : (optional, default is 100) Number of images to download.

    output_dir : (optional, default is 'dataset') Name of output dir.

    adult_filter_off : (optional, default is True) Enable of disable adult filteration.

    force_replace : (optional, default is False) Delete folder if present and start a fresh download.

    timeout : (optional, default is 60) timeout for connection in seconds.

    Further Reference: https://pypi.org/project/bing-image-downloader/

    0 讨论(0)
提交回复
热议问题