|
@@ -1,8 +1,21 @@
|
|
|
from lxml import etree
|
|
|
import urllib.request
|
|
|
+import os
|
|
|
+from argparse import ArgumentParser
|
|
|
|
|
|
-URL = "https://finetuned.nl/freshrss/p/i/?a=rss&rid=610659e817a51&hours=168"
|
|
|
-FILE = open("rss.html", "w")
|
|
|
+parser = ArgumentParser()
|
|
|
+parser.add_argument("url", type=str)
|
|
|
+parser.add_argument("output", type=str)
|
|
|
+args = parser.parse_args()
|
|
|
+
|
|
|
+URL = args.url
|
|
|
+DIR = args.output
|
|
|
+
|
|
|
+if not os.path.exists(DIR):
|
|
|
+ os.makedirs(DIR)
|
|
|
+os.makedirs(os.path.join(DIR, "articles"))
|
|
|
+
|
|
|
+FILE = open(os.path.join(DIR, "index.html"), "w")
|
|
|
|
|
|
print("<html>", file=FILE)
|
|
|
print("<head>", file=FILE)
|
|
@@ -27,7 +40,7 @@ for item in channel.iterfind("item"):
|
|
|
guid = item.find("guid").text
|
|
|
contents = item.find("description").text
|
|
|
print(f"<li><a href=\"articles/{guid}.html\">{title}</a></li>", file=FILE)
|
|
|
- with open(f"articles/{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)
|