from lxml import etree
import urllib.request
import os
from argparse import ArgumentParser
from datetime import datetime
parser = ArgumentParser()
parser.add_argument("url", type=str)
parser.add_argument("output", type=str)
args = parser.parse_args()
HEADER = """
RSS Feed
"""
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(HEADER, file=FILE)
print("RSS Feed
", file=FILE)
print(f"Bijgewerkt: {datetime.now().strftime('%d-%m-%Y %H:%M uur')}", 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
link = item.find("link").text
print(f"- {title}
", file=FILE)
with open(os.path.join(DIR, "articles", f"{guid}.html"), "w") as file:
print(HEADER, file=file)
print(f"Original article: {link}
", file=file)
print(f"{title}
", file=file)
print(contents, file=file)
print("", file=file)
print("", file=file)
print("
", file=FILE)
print("