Make connection more reliable

This commit is contained in:
Benjamin Loison 2024-04-03 19:52:08 +02:00
parent 0e871cf913
commit 7cffb7e37a
No known key found for this signature in database

View File

@ -30,7 +30,12 @@ def treatSuffixes(prefix):
print('From file') print('From file')
except: except:
params['qe'] = base 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. # Pay attention if change `base` elaboration to not allow unwanted folder file writing.
with open(baseFilePath, 'w') as requestFile: with open(baseFilePath, 'w') as requestFile:
requestFile.write(text) requestFile.write(text)