icrawler icon indicating copy to clipboard operation
icrawler copied to clipboard

I want to download the image along with its name

Open nhanlt1 opened this issue 2 years ago • 0 comments

like when you google search it will show the image and the text below it code python below:

def auto_down_img(_keyword):
    rm_temp()
    create_Temp_img()

    class DefaultNameDownloader(ImageDownloader):
        def get_filename(self, task, default_ext):
            filename = super().get_filename(task, default_ext)
            return filename

    google_crawler = GoogleImageCrawler(
        feeder_threads=1,
        parser_threads=1,
        downloader_threads=4,
        storage={'root_dir': 'Temp_image'},
        downloader_cls=DefaultNameDownloader
    )
    filters = dict(
        size='large',
        # license='commercial,modify',
        date=(None, None))
    google_crawler.crawl(keyword=_keyword, filters=filters, offset=0, max_num=9,
                        min_size=(800, 800), max_size=None, file_idx_offset=0)

This is the code I'm using, it seems that the "class DefaultNameDownloader" doesn't work at all.

nhanlt1 avatar Feb 06 '23 09:02 nhanlt1