update url title finder

This commit is contained in:
iou1name 2021-05-25 17:50:29 -04:00
parent fb1d56d4c4
commit 0f8b590935

View File

@ -10,7 +10,7 @@ import requests
from module import hook, url_callback
HEADERS = {"User-Agent": "Give me your data.", "Range": "bytes=0-4096"}
HEADERS = {"User-Agent": "Give me your data.", "Range": "bytes=0-8192"}
@url_callback('puu.sh/')
def get_puush_fname(bot, url):
@ -82,9 +82,11 @@ def title_auto(bot, trigger):
continue
if not res.headers.get("Content-Type").startswith("text/html"):
continue
if res.text.find("<title>") == -1:
if res.text.find("<title") == -1:
continue
title = res.text[res.text.find("<title>")+7:res.text.find("</title>")]
data = res.text[res.text.find("<title"):]
data = re.sub("<title.*?>", "", data)
title = data[:data.find("</title>")]
title = html.unescape(title)
title = title.replace("\n","").strip()
hostname = urlparse(url).hostname