-
Notifications
You must be signed in to change notification settings - Fork 0
/
html_formatter.py
36 lines (32 loc) · 985 Bytes
/
html_formatter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from typing import List
from web_scraper import get_image_urls
def format_as_html(content: str) -> str:
"""
Formats the given content as HTML, including images.
Args:
content (str): The content to format.
Returns:
str: The formatted HTML content.
"""
image_urls = get_image_urls()
html = f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search Results</title>
<style>
body {{ font-family: Arial, sans-serif; line-height: 1.6; padding: 20px; }}
img {{ max-width: 100%; height: auto; margin: 10px 0; }}
</style>
</head>
<body>
<h1>Search Results</h1>
<div>{content}</div>
<h2>Related Images</h2>
{''.join(f'<img src="{url}" alt="Related image">' for url in image_urls[:5])}
</body>
</html>
"""
return html