feedgenerator

A simple tool to create various feeds
git clone https://git.ortlepp.eu/feedgenerator.git/
Log | Files | Refs | README | LICENSE

commit 7bc64edeb17e1d4923bbe6c4fc9f85c94077108e
parent e5b7ada0504e8274b155dd92dc307839413c999b
Author: Thorsten Ortlepp <post@ortlepp.eu>
Date:   Mon, 21 Mar 2022 23:01:57 +0100

Switched feed parsing to feedparser

Diffstat:
M.gitignore | 2+-
Mdeutschlandfunk.py | 10+++++-----
Mrequirements.txt | 1+
3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,4 +1,4 @@ __pycache__ antenne_muenster.xml -deutschlandfunk.sqlite +feedgenerator.sqlite deutschlandfunk.xml diff --git a/deutschlandfunk.py b/deutschlandfunk.py @@ -4,6 +4,7 @@ import requests import sqlite3 import datetime import re +import feedparser from bs4 import BeautifulSoup from common import AtomFeed, FeedItem, Config @@ -75,13 +76,12 @@ class DeutschlandfunkFeed: request = requests.get(self.FEED_URL) if request.status_code == 200: - feed = BeautifulSoup(request.text, "html.parser") - articles = feed.findAll('item') + feed = feedparser.parse(request.text) - for article in articles: - title = article.title.text + for entry in feed.entries: + title = entry.title key = title.strip().lower() - link = self.FEED_BASEURL + article.guid.text + ".html" + link = entry.link count = 0 cursor.execute(self.SQLITE_SQL_CHECK, (key,)) diff --git a/requirements.txt b/requirements.txt @@ -2,6 +2,7 @@ requests bs4 tzdata +feedparser # Needed only up to Python 3.8 backports.zoneinfo