kindlerss.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from lxml import etree
  2. import urllib.request
  3. URL = "https://finetuned.nl/freshrss/p/i/?a=rss&rid=610659e817a51&hours=168"
  4. FILE = open("rss.html", "w")
  5. print("<html>", file=FILE)
  6. print("<head>", file=FILE)
  7. print("<meta charset=\"UTF-8\">", file=FILE)
  8. print("<title>RSS Feed</title>", file=FILE)
  9. print("<style>", file=FILE)
  10. print("* { font-family: sans-serif; line-height: 1.6em;}", file=FILE)
  11. print("a:link { color: black }", file=FILE)
  12. print("a:visited { color: #888 }", file=FILE)
  13. print("</style>", file=FILE)
  14. print("</head>", file=FILE)
  15. print("<bady>", file=FILE)
  16. print("<h1>RSS Feed</h1>", file=FILE)
  17. print("<ul>", file=FILE)
  18. feed = urllib.request.urlopen("https://finetuned.nl/freshrss/p/i/?a=rss&rid=610659e817a51&hours=168")
  19. feed = etree.parse(feed)
  20. feed = feed.getroot()
  21. channel = feed.find("channel")
  22. for item in channel.iterfind("item"):
  23. title = item.find("title").text
  24. guid = item.find("guid").text
  25. contents = item.find("description").text
  26. print(f"<li><a href=\"articles/{guid}.html\">{title}</a></li>", file=FILE)
  27. with open(f"articles/{guid}.html", "w") as file:
  28. print("<html>", file=file)
  29. print("<head>", file=file)
  30. print("<meta charset=\"UTF-8\">", file=file)
  31. print("<title>RSS Feed</title>", file=file)
  32. print("</head>", file=file)
  33. print("<bady>", file=file)
  34. print(contents, file=file)
  35. print("</body>", file=file)
  36. print("</html>", file=file)
  37. print("</ul>", file=FILE)
  38. print("</body>", file=FILE)
  39. print("</html>", file=FILE)
  40. FILE.close()