From 7cffb7e37a250b76897f1341cc55c454c14af6fd Mon Sep 17 00:00:00 2001 From: Benjamin Loison <12752145+Benjamin-Loison@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:52:08 +0200 Subject: [PATCH] Make connection more reliable --- main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index a2baf8b..815516b 100755 --- a/main.py +++ b/main.py @@ -30,7 +30,12 @@ def treatSuffixes(prefix): print('From file') except: params['qe'] = base - text = requests.get(url, params = params).text + while True: + try: + text = requests.get(url, params = params).text + break + except requests.exceptions.ConnectionError: + continue # Pay attention if change `base` elaboration to not allow unwanted folder file writing. with open(baseFilePath, 'w') as requestFile: requestFile.write(text)