Update app.py
Browse files
app.py
CHANGED
|
@@ -52,16 +52,13 @@ def extract_images(soup, base_url):
|
|
| 52 |
full_img_url = urljoin(base_url, img_url) if not img_url.startswith(("http://", "https://")) else img_url
|
| 53 |
alt_text = img.get('alt', 'No Alt Text')
|
| 54 |
images.append({"Alt Text": alt_text, "Image URL": full_img_url})
|
| 55 |
-
|
| 56 |
|
| 57 |
def format_detailed_output(structured_data, title):
|
| 58 |
-
"""Formats the structured data into a Markdown string
|
| 59 |
result = f"### Title\n\n{title}\n\n"
|
| 60 |
result += "### Texts\n\n"
|
| 61 |
-
if structured_data["Texts"]
|
| 62 |
-
result += "\n".join(structured_data["Texts"])
|
| 63 |
-
else:
|
| 64 |
-
result += "No textual content found."
|
| 65 |
result += "\n\n### Links\n\n"
|
| 66 |
if structured_data["Links"]:
|
| 67 |
result += "\n".join(f"[{link['Text']}]({link['URL']})" for link in structured_data["Links"])
|
|
|
|
| 52 |
full_img_url = urljoin(base_url, img_url) if not img_url.startswith(("http://", "https://")) else img_url
|
| 53 |
alt_text = img.get('alt', 'No Alt Text')
|
| 54 |
images.append({"Alt Text": alt_text, "Image URL": full_img_url})
|
| 55 |
+
return images
|
| 56 |
|
| 57 |
def format_detailed_output(structured_data, title):
|
| 58 |
+
"""Formats the structured data into a Markdown string."""
|
| 59 |
result = f"### Title\n\n{title}\n\n"
|
| 60 |
result += "### Texts\n\n"
|
| 61 |
+
result += " ".join(structured_data["Texts"]) if structured_data["Texts"] else "No textual content found."
|
|
|
|
|
|
|
|
|
|
| 62 |
result += "\n\n### Links\n\n"
|
| 63 |
if structured_data["Links"]:
|
| 64 |
result += "\n".join(f"[{link['Text']}]({link['URL']})" for link in structured_data["Links"])
|