From f1f8c1810a9282acdace45066af0804057465446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gl=C3=BCpker?= Date: Thu, 25 Nov 2021 14:01:05 +0100 Subject: Add zammad release notes page --- zammad.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 zammad.py (limited to 'zammad.py') diff --git a/zammad.py b/zammad.py new file mode 100755 index 0000000..fd0401a --- /dev/null +++ b/zammad.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +import logging +from datetime import datetime +from urllib.request import Request, urlopen + +from bs4 import BeautifulSoup + + +def zammad(): + url = "https://zammad.com/en/releases" + try: + res = urlopen(Request(url)) + except Exception as exc: + logging.error("Request to zammad failed.", exc_info=exc) + return None + + try: + soup = BeautifulSoup(res, features="html.parser") + except Exception as exc: + logging.error("Parsing to zammad failed.", exc_info=exc) + return None + + releases = soup.find_all("a", attrs={"class": "press-article"}) + return { + "title": "Zammad Release Notes", + "url": url, + "description": "Release Notes for Zammad.", + "content": [ + { + "title": release.find(attrs={"class": "press-article-title"}).text, + "url": release.attrs.get("href"), + "content": release.find("p").text, + "date": datetime.strptime( + " ".join( + release.find( + attrs={"class": "press-article-detail"} + ).text.split()[:3] + ), + "%d %B %Y", + ), + } + for release in releases + ], + } + + +def main(): + print(zammad()) + + +if __name__ == "__main__": + main() -- cgit v1.2.3