error handling

This commit is contained in:
Christian Jeworrek
2025-02-27 20:55:03 +01:00
parent 256e33916d
commit 8872db6767

View File

@@ -29,6 +29,7 @@ for mysoup in soup.find_all('article', class_='teaser-element'):
mylist = []
mykeywords = myunits = ""
for itemsoup in (soup2.find('tbody').find_all('td')):
if itemsoup.string is not None:
mylist.append(re.sub(r"\n\ *", " ", itemsoup.string.strip()))
if len(mylist) >= 4:
mykeywords = mylist[3]
@@ -40,6 +41,9 @@ for mysoup in soup.find_all('article', class_='teaser-element'):
locale.setlocale(locale.LC_TIME, 'de_DE.UTF-8')
print("<title>" + mykeywords + " - " + (mysoup.find('h3', class_="heading")).string.strip() + " - " + myunits + "</title>")
print("<link>" + mylink + "</link>")
try:
print("<description>" + (mysoup.find('div', class_="teaser-element-text")).string.strip() + "</description>")
except:
print("<description></description>")
print("</item>")
print("</channel></rss>")