From afaa20032fc773b9d2b0a1b7ac34ccabc70458d3 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Tue, 29 Sep 2020 21:34:40 -0500 Subject: Add Peanuts --- on_this_day.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/on_this_day.py b/on_this_day.py index f8abb8e..5813f18 100644 --- a/on_this_day.py +++ b/on_this_day.py @@ -6,7 +6,7 @@ from bs4 import BeautifulSoup from config import config def get_on_this_day(): - return "

On this day

%s%s%s%s" % (get_old_news(), get_calvin_and_hobbes(), get_today_wikipedia(), get_today_wikiquote()) + return "

On this day

%s" % (get_old_news(), get_peanuts(), get_calvin_and_hobbes(), get_today_wikipedia(), get_today_wikiquote()) def get_old_news(): print("getting old news") @@ -49,3 +49,12 @@ def get_calvin_and_hobbes(): else: return "" +def get_peanuts(): + print("getting peanuts") + comic_date = date.today().strftime("%Y/%m/%d") + full_url = "https://www.gocomics.com/peanuts/%s" % comic_date + r = requests.get(full_url) + soup = BeautifulSoup(r.text, features="lxml") + comic_src = soup.select(".item-comic-image")[0].img["src"] + return '
Peanuts
' % (comic_src) + -- cgit v1.2.3