|
@@ -8,6 +8,19 @@ parser.add_argument("url", type=str)
|
|
parser.add_argument("output", type=str)
|
|
parser.add_argument("output", type=str)
|
|
args = parser.parse_args()
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
+HEADER = """<!DOCTYPE HTML>
|
|
|
|
+<html>
|
|
|
|
+<head>
|
|
|
|
+<meta charset="utf-8">
|
|
|
|
+<title>RSS Feed</title>
|
|
|
|
+<style>
|
|
|
|
+* { font-family: sans-serif; line-height: 1.6em;}
|
|
|
|
+a:link { color: black }
|
|
|
|
+a:visited {color: #666 }
|
|
|
|
+</style>
|
|
|
|
+</head>
|
|
|
|
+<body>"""
|
|
|
|
+
|
|
URL = args.url
|
|
URL = args.url
|
|
DIR = args.output
|
|
DIR = args.output
|
|
|
|
|
|
@@ -17,17 +30,7 @@ os.makedirs(os.path.join(DIR, "articles"), exist_ok=True)
|
|
|
|
|
|
FILE = open(os.path.join(DIR, "index.html"), "w")
|
|
FILE = open(os.path.join(DIR, "index.html"), "w")
|
|
|
|
|
|
-print("<html>", file=FILE)
|
|
|
|
-print("<head>", file=FILE)
|
|
|
|
-print("<meta charset=\"UTF-8\">", file=FILE)
|
|
|
|
-print("<title>RSS Feed</title>", file=FILE)
|
|
|
|
-print("<style>", file=FILE)
|
|
|
|
-print("* { font-family: sans-serif; line-height: 1.6em;}", file=FILE)
|
|
|
|
-print("a:link { color: black }", file=FILE)
|
|
|
|
-print("a:visited { color: #888 }", file=FILE)
|
|
|
|
-print("</style>", file=FILE)
|
|
|
|
-print("</head>", file=FILE)
|
|
|
|
-print("<bady>", file=FILE)
|
|
|
|
|
|
+print(HEADER, file=FILE)
|
|
print("<h1>RSS Feed</h1>", file=FILE)
|
|
print("<h1>RSS Feed</h1>", file=FILE)
|
|
print("<ul>", file=FILE)
|
|
print("<ul>", file=FILE)
|
|
|
|
|
|
@@ -41,17 +44,8 @@ for item in channel.iterfind("item"):
|
|
contents = item.find("description").text
|
|
contents = item.find("description").text
|
|
print(f"<li><a href=\"articles/{guid}.html\">{title}</a></li>", file=FILE)
|
|
print(f"<li><a href=\"articles/{guid}.html\">{title}</a></li>", file=FILE)
|
|
with open(os.path.join(DIR, "articles", f"{guid}.html"), "w") as file:
|
|
with open(os.path.join(DIR, "articles", f"{guid}.html"), "w") as file:
|
|
- print("<html>", file=file)
|
|
|
|
- print("<head>", file=file)
|
|
|
|
- print("<meta charset=\"UTF-8\">", file=file)
|
|
|
|
- print("<title>RSS Feed</title>", file=file)
|
|
|
|
- print("<style>", file=file)
|
|
|
|
- print("* { font-family: sans-serif; line-height: 1.6em;}", file=file)
|
|
|
|
- print("a:link { color: black }", file=file)
|
|
|
|
- print("a:visited { color: #888 }", file=file)
|
|
|
|
- print("</style>", file=file)
|
|
|
|
- print("</head>", file=file)
|
|
|
|
- print("<bady>", file=file)
|
|
|
|
|
|
+ print(HEADER, file=file)
|
|
|
|
+ print(f"<h1>{title}</h1>", file=file)
|
|
print(contents, file=file)
|
|
print(contents, file=file)
|
|
print("</body>", file=file)
|
|
print("</body>", file=file)
|
|
print("</html>", file=file)
|
|
print("</html>", file=file)
|