Browse Source

fixed html encoding

master
Angerstoner 6 years ago
parent
commit
1f4a45a596
  1. 6
      coding_love.py

6
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">(.*)</h1>', random_page_content).group(1)
gif_match = re.search('data="(.*)" type="image/gif"', random_page_content)

Loading…
Cancel
Save