mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 17:44:50 +00:00
Salah escape text
This commit is contained in:
parent
6be3ff1064
commit
51ffce69a3
3 changed files with 8 additions and 6 deletions
|
|
@ -8,6 +8,7 @@ import pickle
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from inspect import getfullargspec
|
from inspect import getfullargspec
|
||||||
from shutil import disk_usage
|
from shutil import disk_usage
|
||||||
|
|
@ -420,6 +421,7 @@ async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]:
|
||||||
"fetch": fetch,
|
"fetch": fetch,
|
||||||
"replied": ctx.reply_to_message,
|
"replied": ctx.reply_to_message,
|
||||||
"requests": requests,
|
"requests": requests,
|
||||||
|
"soup": BeautifulSoup,
|
||||||
"help": _help,
|
"help": _help,
|
||||||
}
|
}
|
||||||
eval_vars.update(var)
|
eval_vars.update(var)
|
||||||
|
|
|
||||||
|
|
@ -236,8 +236,8 @@ async def inline_menu(_, inline_query: InlineQuery):
|
||||||
snippet = result.select_one("#rso .lyLwlc").text
|
snippet = result.select_one("#rso .lyLwlc").text
|
||||||
except:
|
except:
|
||||||
snippet = "-"
|
snippet = "-"
|
||||||
message_text = f"<a href='{link}'>{title}</a>\n"
|
message_text = f"<a href='{link}'>{html.escape(title)}</a>\n"
|
||||||
message_text += f"Deskription: {html.escape(snippet)}"
|
message_text += f"Deskription: {html.escape(snippet)}\nGoogleSearch by @{self.me.username}"
|
||||||
data.append(
|
data.append(
|
||||||
InlineQueryResultArticle(
|
InlineQueryResultArticle(
|
||||||
title=f"{title}",
|
title=f"{title}",
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ async def gsearch(_, message):
|
||||||
# collect data
|
# collect data
|
||||||
data = []
|
data = []
|
||||||
|
|
||||||
for result in soup.select(".tF2Cxc"):
|
for result in soup.select(".tF2Cxc"):hmm
|
||||||
link = result.select_one(".yuRUbf a")["href"]
|
link = result.select_one(".yuRUbf a")["href"]
|
||||||
title = result.select_one(".DKV0Md").text
|
title = result.select_one(".DKV0Md").text
|
||||||
try:
|
try:
|
||||||
|
|
@ -219,16 +219,16 @@ async def gsearch(_, message):
|
||||||
# appending data to an array
|
# appending data to an array
|
||||||
data.append(
|
data.append(
|
||||||
{
|
{
|
||||||
"title": title,
|
"title": html.escape(title),
|
||||||
"link": link,
|
"link": link,
|
||||||
"snippet": snippet,
|
"snippet": html.escape(snippet),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
arr = json.dumps(data, indent=2, ensure_ascii=False)
|
arr = json.dumps(data, indent=2, ensure_ascii=False)
|
||||||
parse = json.loads(arr)
|
parse = json.loads(arr)
|
||||||
total = len(parse)
|
total = len(parse)
|
||||||
res = "".join(
|
res = "".join(
|
||||||
f"<a href='{i['link']}'>{i['title']}</a>\n{html.escape(i['snippet'])}\n\n"
|
f"<a href='{i['link']}'>{i['title']}</a>\n{i['snippet']}\n\n"
|
||||||
for i in parse
|
for i in parse
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue