[PYTHON] [Icrawler] How to download images even after changing Google specifications (after March 2023)

Nice to meet you. I'm a liberal arts college student. I am biting deep learning as a hobby.

I always used icrawler when I wanted to recognize the pictures of my favorite idols and characters. However, with the conventional method, it suddenly became impossible ... (It seems that the specifications have changed since 2020.03.) Below is the code that I have been able to use. (This will give an error.)

get_image.py


from icrawler.builtin import GoogleImageCrawler
import sys
import os

argv = sys.argv

if not os.path.isdir(argv[1]):
    os.makedirs(argv[1])


crawler = GoogleImageCrawler(storage = {"root_dir" : argv[1]})
crawler.crawl(keyword = argv[2], max_num = 1000)

The code that can be used after the change

get_image.py


from icrawler.builtin import BingImageCrawler
import sys
import os

argv = sys.argv

if not os.path.isdir(argv[1]):
    os.makedirs(argv[1])


crawler = BingImageCrawler(storage = {"root_dir" : argv[1]})
crawler.crawl(keyword = argv[2], max_num = 1000)

is. It worked !!!!!!! It seems to work if you replace GoogleImageCrawler with BingImageCrawler.

By the way, if you want to run this program, you should type the following in the terminal! !!

$ python get_imeg.py */Directory you want to save Image name you want to search
python get_image.py */The directory where you want to save the downloaded image The name of the image you want to download (for example, Mai Shiraishi)

Bakusho Mondai: When executed in Tanaka, it will be automatically collected as shown below. スクリーンショット 2020-04-19 17.16.35.png

Come on for deep learning! !! !! With this, the flow of one series is covered! !! Ota faction of the laughter problem? Tanaka faction? (Introduction to image recognition)

Quote https://qiita.com/NakaokaRei/items/8c7e7b1f2c0c7ef8b3a3

Recommended Posts

[Icrawler] How to download images even after changing Google specifications (after March 2023)
How to deal with UnicodeDecodeError when executing google image download
How to use Google Colaboratory
[Rails] How to display Google Map
How to collect images in Python
[Memo] How to use Google MµG