sushi / get_images.py
seamusbarnes
wrote script for downloading images and downloaded images
ce50866
raw
history blame contribute delete
775 Bytes
from fastbook import *
def download_single_image(term, folder, attempts=10):
file_path = Path(os.path.join(folder, f'{term}.jpg'))
urls = search_images_ddg(f'tasty {term}', max_images=10)
for i in range(attempts):
try:
download_url(urls[i], file_path, show_progress=False)
break
except Exception as e:
print(f'Error on attempt {i+1}: {e}')
if __name__ == '__main__':
terms = [
'sushi',
'udon',
'tofu',
'tempura',
'ramen',
'donburi',
'oden',
'soba',
'miso soup',
'okonomiyaki',
'gyoza',
'takoyaki',
'edamame',
'yakisoba',
'chawanmushi',
'wagashi',
'sashimi']
for term in terms:
download_single_image(term, 'images')