1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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()
|