fix title parsing library reference
This commit is contained in:
parent
20199379c2
commit
64953ae402
|
@ -3,8 +3,8 @@
|
||||||
URL parsing.
|
URL parsing.
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
|
import html
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from html.parser import HTMLParser
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ def title_auto(bot, trigger):
|
||||||
if res.text.find("<title>") == -1:
|
if res.text.find("<title>") == -1:
|
||||||
continue
|
continue
|
||||||
title = res.text[res.text.find("<title>")+7:res.text.find("</title>")]
|
title = res.text[res.text.find("<title>")+7:res.text.find("</title>")]
|
||||||
title = HTMLParser().unescape(title)
|
title = html.unescape(title)
|
||||||
title = title.replace("\n","").strip()
|
title = title.replace("\n","").strip()
|
||||||
hostname = urlparse(url).hostname
|
hostname = urlparse(url).hostname
|
||||||
bot.msg(f"[ \x0310{title} \x03] - \x0304{hostname}")
|
bot.msg(f"[ \x0310{title} \x03] - \x0304{hostname}")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user