Spaces:
Sleeping
Sleeping
Commit
·
53af5d4
1
Parent(s):
f3af12d
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,14 @@ import logging
|
|
20 |
logging.basicConfig(level=logging.INFO)
|
21 |
|
22 |
def download_pdf(url, output_path):
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
def preprocess(text):
|
26 |
text = text.replace('\n', ' ')
|
|
|
20 |
logging.basicConfig(level=logging.INFO)
|
21 |
|
22 |
def download_pdf(url, output_path):
|
23 |
+
try:
|
24 |
+
urllib.request.urlretrieve(url, output_path)
|
25 |
+
except urllib.error.HTTPError as e:
|
26 |
+
if e.code == 429:
|
27 |
+
time.sleep(1) # Wait for 1 second before retrying
|
28 |
+
download_pdf(url, output_path)
|
29 |
+
else:
|
30 |
+
raise
|
31 |
|
32 |
def preprocess(text):
|
33 |
text = text.replace('\n', ' ')
|