diff options
author | Mark Powers <markppowers0@gmail.com> | 2020-09-29 21:34:40 -0500 |
---|---|---|
committer | Mark Powers <markppowers0@gmail.com> | 2020-09-29 21:34:40 -0500 |
commit | afaa20032fc773b9d2b0a1b7ac34ccabc70458d3 (patch) | |
tree | 19557bec2cc9dcf6f13445b1721496accd3ecac8 | |
parent | 0f9519ade58173de0b564058ff7588b471cd7c65 (diff) |
Add Peanuts
-rw-r--r-- | on_this_day.py | 11 |
1 files changed, 10 insertions, 1 deletions
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 "<h1>On this day</h1>%s%s%s%s" % (get_old_news(), get_calvin_and_hobbes(), get_today_wikipedia(), get_today_wikiquote()) + return "<h1>On this day</h1><ul><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>%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 '<div><a href="%s">Peanuts</a></div>' % (comic_src) + |