File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
html-css-python/python_scripts Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 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>" )
Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments