From 1f4a45a5968b0a9726481878111c0ae9ab3852eb Mon Sep 17 00:00:00 2001 From: Angerstoner Date: Thu, 7 Feb 2019 15:59:38 +0100 Subject: [PATCH] fixed html encoding --- coding_love.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/coding_love.py b/coding_love.py index e4208a7..d15a539 100644 --- a/coding_love.py +++ b/coding_love.py @@ -1,5 +1,6 @@ import requests import re +import html url = "https://thecodinglove.com/" @@ -7,7 +8,10 @@ url = "https://thecodinglove.com/" def send_coding_love_gif(bot, update): random_url = re.search('href="(.*)".*\n.*random\(\)', requests.get(url).text).group(1) - random_page_content = requests.get(random_url).text + random_page_content = requests.get(random_url) + random_page_content.encoding = 'utf-8' + random_page_content = html.unescape(random_page_content.text) + caption = re.search('blog-post-title">(.*)', random_page_content).group(1) gif_match = re.search('data="(.*)" type="image/gif"', random_page_content)