Trying add default chrome user agent

This commit is contained in:
yasirarism 2023-08-19 21:45:06 +07:00 committed by GitHub
parent ec4285eaee
commit 6e10d9c68c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 8 deletions

View file

@ -10,7 +10,8 @@ session = ClientSession()
http = httpx.AsyncClient( http = httpx.AsyncClient(
http2=True, http2=True,
verify=False, verify=False,
timeout=httpx.Timeout(40), headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edge/107.0.1418.42"}
timeout=httpx.Timeout(10),
) )

View file

@ -6,6 +6,7 @@ import json
import os import os
import pickle import pickle
import re import re
import requests
import sys import sys
import traceback import traceback
from datetime import datetime from datetime import datetime
@ -364,12 +365,11 @@ async def shell_cmd(_, ctx: Message, strings):
& filters.user(SUDO) & filters.user(SUDO)
) )
@app.on_edited_message( @app.on_edited_message(
(filters.command(["ev", "run", "myeval"]) | filters.regex(r"app.run\(\)$")) (filters.command(["ev", "run", "meval"]) | filters.regex(r"app.run\(\)$"))
& filters.user(SUDO) & filters.user(SUDO)
) )
@user.on_message(filters.command(["ev", "run", "myeval"], ".") & filters.me) @user.on_message(filters.command(["ev", "run", "meval"], ".") & filters.me)
@use_chat_lang() @use_chat_lang()
@new_task
async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]: async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]:
if (ctx.command and len(ctx.command) == 1) or ctx.text == "app.run()": if (ctx.command and len(ctx.command) == 1) or ctx.text == "app.run()":
return await edit_or_reply(ctx, text=strings("no_eval")) return await edit_or_reply(ctx, text=strings("no_eval"))
@ -419,6 +419,7 @@ async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]:
"traceback": traceback, "traceback": traceback,
"http": http, "http": http,
"replied": ctx.reply_to_message, "replied": ctx.reply_to_message,
"requests": requests,
"help": _help, "help": _help,
} }
eval_vars.update(var) eval_vars.update(var)

View file

@ -229,11 +229,8 @@ async def inline_menu(_, inline_query: InlineQuery):
switch_pm_parameter="inline", switch_pm_parameter="inline",
) )
judul = inline_query.query.split(None, 1)[1].strip() judul = inline_query.query.split(None, 1)[1].strip()
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edge/107.0.1418.42"
}
search_results = await http.get( search_results = await http.get(
f"https://www.google.com/search?q={judul}&num=20", headers=headers f"https://www.google.com/search?q={judul}&num=20"
) )
soup = BeautifulSoup(search_results.text, "lxml") soup = BeautifulSoup(search_results.text, "lxml")
data = [] data = []