summaryrefslogtreecommitdiff
path: root/netto.py
diff options
context:
space:
mode:
authorAndré Glüpker <git@wgmd.de>2021-07-29 10:48:55 +0200
committerAndré Glüpker <git@wgmd.de>2021-07-29 10:51:55 +0200
commitb526cc68929250a7f71ff21ed8410ffd8db87a9d (patch)
tree54ff4b25b4eea9a142a46741eaf502116b030383 /netto.py
parentaf15eade0f59c17c4867baffe0e1dc05033b06c8 (diff)
downloadrss-feeds-b526cc68929250a7f71ff21ed8410ffd8db87a9d.tar.gz
rss-feeds-b526cc68929250a7f71ff21ed8410ffd8db87a9d.tar.bz2
rss-feeds-b526cc68929250a7f71ff21ed8410ffd8db87a9d.zip
Format using black
Diffstat (limited to 'netto.py')
-rwxr-xr-xnetto.py49
1 files changed, 18 insertions, 31 deletions
diff --git a/netto.py b/netto.py
index 2867edf..3f1beb2 100755
--- a/netto.py
+++ b/netto.py
@@ -5,50 +5,37 @@ from datetime import datetime
from bs4 import BeautifulSoup
import sys
-def _format_date(dt):
- """convert a datetime into an RFC 822 formatted date
- Input date must be in GMT.
- Stolen from PyRSS2Gen.
- """
- # Looks like:
- # Sat, 07 Sep 2002 00:00:01 GMT
- # Can't use strftime because that's locale dependent
- #
- # Isn't there a standard way to do this for Python? The
- # rfc822 and email.Utils modules assume a timestamp. The
- # following is based on the rfc822 module.
- return "%s, %02d %s %04d %02d:%02d:%02d GMT" % (
- ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][dt.weekday()],
- dt.day,
- ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][dt.month-1],
- dt.year, dt.hour, dt.minute, dt.second)
def netto(store_id):
- url = 'https://www.netto-online.de/ueber-netto/Online-Prospekte.chtm/' + str(store_id)
+ url = "https://www.netto-online.de/ueber-netto/Online-Prospekte.chtm/" + str(
+ store_id
+ )
res = urlopen(Request(url))
soup = BeautifulSoup(res, features="html.parser")
# messages = soup.find_all('div', attrs={'class': 'tgme_widget_message_wrap'})
- message = soup.find('a', attrs={'class': 'flipbook_pdf_flipbook'})
+ message = soup.find("a", attrs={"class": "flipbook_pdf_flipbook"})
- url = message['href'].split('?')[0]
+ url = message["href"].split("?")[0]
year = str(datetime.now().year)
- title = url[ url.find(year) : url.find(year) + 7 ]
+ title = url[url.find(year) : url.find(year) + 7]
return {
- title: 'Netto Angebote für ' + store_id,
- url: 'https://www.netto-online.de/ueber-netto/Online-Prospekte.chtm/' + store_id,
- description: 'PDF der neuen Netto Angebote für den Laden um die Ecke.',
- content: [{
- 'title': 'Angebote für ' + title,
- 'url': url,
- 'content': 'Angebote für ' + title + ' finden sich unter ' + url,
- }]
+ title: "Netto Angebote für " + store_id,
+ url: "https://www.netto-online.de/ueber-netto/Online-Prospekte.chtm/"
+ + store_id,
+ description: "PDF der neuen Netto Angebote für den Laden um die Ecke.",
+ content: [
+ {
+ "title": "Angebote für " + title,
+ "url": url,
+ "content": "Angebote für " + title + " finden sich unter " + url,
+ }
+ ],
}
-def main(store_id = 9110):
+def main(store_id=9110):
print(netto(store_id))