import fastai from fastai.vision.all import * import timm from PIL import Image from pathlib import Path from os import path from tqdm.auto import tqdm from urllib.error import HTTPError, URLError def search_images_ddg(term, max_images=200): "Search for `term` with DuckDuckGo and return a unique urls of about `max_images` images" assert max_images<1000 url = 'https://duckduckgo.com/' res = urlread(url,data={'q':term}) searchObj = re.search(r'vqd=([\d-]+)\&', res) assert searchObj requestUrl = url + 'i.js' params = dict(l='us-en', o='json', q=term, vqd=searchObj.group(1), f=',,,', p='1', v7exp='a') urls,data = set(),{'next':1} headers = dict(referer='https://duckduckgo.com/') while len(urls)