from lxml import etree
import urllib.request
import os
from argparse import ArgumentParser
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"), exist_ok=True)
FILE = open(os.path.join(DIR, "index.html"), "w")
print("", file=FILE)
print("
", file=FILE)
print("", file=FILE)
print("RSS Feed", file=FILE)
print("", file=FILE)
print("", file=FILE)
print("", file=FILE)
print("RSS Feed
", file=FILE)
print("", file=FILE)
feed = urllib.request.urlopen("https://finetuned.nl/freshrss/p/i/?a=rss&rid=610659e817a51&hours=168")
feed = etree.parse(feed)
feed = feed.getroot()
channel = feed.find("channel")
for item in channel.iterfind("item"):
title = item.find("title").text
guid = item.find("guid").text
contents = item.find("description").text
print(f"- {title}
", file=FILE)
with open(os.path.join(DIR, "articles", f"{guid}.html"), "w") as file:
print("", file=file)
print("", file=file)
print("", file=file)
print("RSS Feed", file=file)
print("", file=FILE)
print("", file=file)
print("", file=file)
print(contents, file=file)
print("", file=file)
print("", file=file)
print("
", file=FILE)
print("