Exception, wenn Feed nicht erreichbar

This commit is contained in:
Andreas Bielawski 2017-05-08 12:39:04 +02:00
parent 2bd88e767a
commit 00e4acfd35

5
bot.py
View File

@ -318,6 +318,7 @@ def check_rss(bot, job):
last = r.get('pythonbot:rss:' + url + ':last_entry') last = r.get('pythonbot:rss:' + url + ':last_entry')
feed_data = feedparser.parse(url) feed_data = feedparser.parse(url)
try:
if feed_data.status < 400: if feed_data.status < 400:
if not 'title' in feed_data.feed: if not 'title' in feed_data.feed:
feed_title = feed_data.feed.link feed_title = feed_data.feed.link
@ -378,7 +379,9 @@ def check_rss(bot, job):
bot.sendMessage(e.new_chat_id, text, parse_mode=ParseMode.HTML, disable_web_page_preview=True) bot.sendMessage(e.new_chat_id, text, parse_mode=ParseMode.HTML, disable_web_page_preview=True)
else: else:
print('HTTP-Fehler: ' + str(feed_data.status)) print('HTTP-Fehler: ' + str(feed_data.status))
print('----------') except:
print('Fehler: Seite nicht erreichbar')
print('-----------------------')
def error(bot, update, error): def error(bot, update, error):