Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -22,11 +22,14 @@ def fetch_pdf_text_from_github(urls):
|
|
22 |
response = requests.get(url)
|
23 |
if response.status_code == 200:
|
24 |
pdf_file = BytesIO(response.content)
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
30 |
else:
|
31 |
st.error(f"Failed to fetch PDF from URL: {url}")
|
32 |
return text
|
|
|
22 |
response = requests.get(url)
|
23 |
if response.status_code == 200:
|
24 |
pdf_file = BytesIO(response.content)
|
25 |
+
try:
|
26 |
+
pdf_reader = PdfReader(pdf_file)
|
27 |
+
for page in pdf_reader.pages:
|
28 |
+
page_text = page.extract_text()
|
29 |
+
if page_text:
|
30 |
+
text += page_text
|
31 |
+
except Exception as e:
|
32 |
+
st.error(f"Failed to read PDF from URL {url}: {e}")
|
33 |
else:
|
34 |
st.error(f"Failed to fetch PDF from URL: {url}")
|
35 |
return text
|