KSh100 commited on
Commit
1db6081
·
verified ·
1 Parent(s): c866c44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
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
- return images
56
 
57
  def format_detailed_output(structured_data, title):
58
- """Formats the structured data into a Markdown string with each text, link, and image on a new line."""
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"])