Skip to content

Commit 59fa406

Browse files
committed
Add Pyython scripts
1 parent 462ce26 commit 59fa406

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import unicodedata
2+
3+
all_emoji = "🐞🐍👍🎉🤩😂🐶🍿😎✨💬😘"
4+
columns = ["#", "Emoji", "Name"]
5+
6+
table_head = (
7+
f"<thead>\n<tr><th>{'</th><th>'.join(columns)}</th></tr>\n</thead>"
8+
)
9+
10+
table_body = "\n<tbody>\n"
11+
for i, emoji in enumerate(all_emoji, start=1):
12+
emoji_data = [f"{i}.", emoji, unicodedata.name(emoji).title()]
13+
table_body += f"<tr><td>{'</td><td>'.join(emoji_data)}</td></tr>\n"
14+
table_body += "</tbody>\n"
15+
16+
print(f"<table>\n{table_head}{table_body}</table>")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Note: Place this Python file next to gallery.html
3+
"""
4+
5+
from pathlib import Path
6+
7+
8+
class ImageParser(HTMLParser):
9+
def handle_starttag(self, tag, attrs):
10+
for attr, val in attrs:
11+
if attr == "src" and tag == "img":
12+
print(f"Found Image: {val!r}")
13+
14+
15+
with open("gallery.html", mode="r", encoding="utf-8") as html_file:
16+
html_content = html_file.read()
17+
18+
parser = ImageParser()
19+
parser.feed(html_content)

0 commit comments

Comments
 (0)