This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| from pathlib import Path | |
| from urllib.parse import urlparse | |
| import requests | |
| def get_image(html_tag: str): | |
| # Find src attribute in the HTML tag | |
| src_match = re.search(r'src="([^"]+)"', html_tag) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pathlib import Path | |
| from typing import Final | |
| global SKIP_EXTS | |
| SKIP_EXTS: Final[set[str]] = {".tmp", ".log", ".ini", ".zip", ".lrv", ".insv"} | |
| def count_ext(path: Path) -> dict[str, int]: | |
| """Count the number of files for each file extension in the given directory and its subdirectories. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="ko> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| </head> | |
| <body> | |
| <!-- body contents here --> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Make dictionary. | |
| # Key is the original substring that you want to change. | |
| # Value is the new substring that you want to enter. | |
| replace_words: dict = {"Original substring": "New substring",} | |
| # Call all keys and values in dictionary, escape special character and replace dictionary for replacement with escaped one. | |
| # re.escape will automatically escapes special characters in keys of dictionary (The original substring) | |
| # Only key will be used to make RegEx pattern, so value doesn't need to be escaped. | |
| replace_words: dict = dict((re.escape(k), v) for k, v in replace_words.items()) |