Handle feedparser exception

This commit is contained in:
spla 2021-05-15 11:19:08 +02:00
pare 9ab7d02526
commit 975a752a10
S'han modificat 2 arxius amb 13 adicions i 6 eliminacions

Veure arxiu

@ -3,10 +3,7 @@ import feedparser
from mastodon import Mastodon from mastodon import Mastodon
import psycopg2 import psycopg2
import sys import sys
import time
###############################################################################
# INITIALISATION
###############################################################################
# Returns the parameter from the specified file # Returns the parameter from the specified file
def get_parameter( parameter, file_path ): def get_parameter( parameter, file_path ):
@ -61,7 +58,15 @@ if __name__ == '__main__':
publish = 0 publish = 0
try:
newsfeeds = feedparser.parse(feeds_url) newsfeeds = feedparser.parse(feeds_url)
print(newsfeeds.status)
except:
print(newsfeeds.status)
sys.exit(0)
for entry in newsfeeds.entries: for entry in newsfeeds.entries:
@ -111,6 +116,8 @@ if __name__ == '__main__':
mastodon.status_post(toot_text, in_reply_to_id=None,) mastodon.status_post(toot_text, in_reply_to_id=None,)
time.sleep(2)
######################################################### #########################################################
insert_line = 'INSERT INTO feeds(id, link) VALUES (%s, %s)' insert_line = 'INSERT INTO feeds(id, link) VALUES (%s, %s)'