From c0a8c7b42b6900c0d3d39e1a7a8a91d3aecb193e Mon Sep 17 00:00:00 2001 From: Snipeur060 <61784407+Snipeur060@users.noreply.github.com> Date: Sun, 11 Feb 2024 21:00:01 +0100 Subject: [PATCH] Update getimage.py try except for html file --- train/getimage.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/train/getimage.py b/train/getimage.py index c8dd46c..55a4f1d 100644 --- a/train/getimage.py +++ b/train/getimage.py @@ -20,9 +20,11 @@ def download_google_images(query, num_images,where): os.makedirs(where) print(soup) #on save en local - with open('test.html', 'w') as f: - f.write(str(soup)) - + try: + with open('test.html', 'w') as f: + f.write(str(soup)) + except Exception as e: + print(e) # Télécharger les images image_tags = soup.find_all('a', class_='rg_l') print(image_tags)