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