<filename>Anime_Downloader_Probot/anime_search.py<gh_stars>0
import random
from pyrogram import *
from pyrogram.types import *
from requests_html import HTMLSession
from bs4 import BeautifulSoup

# Searching anime by regex pattern "/search <space> Anime Name"

STICKERS = (
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "CAACAgUAAxkBAAECXYpgtiiK60ASuhzn5HF1hqlCyeWYHQACYQUAAo8k-yU17VzPXRipPB8E",
    "CAACAgUAAxkBAAECXYxgtiieT0cYvIYTwqzAPPOi-x-IIgACYwUAAo8k-yVtsLZX7RZPZx8E",
)


def anime_search(client, message):
    q = message.text
    q1 = q.split()
    q1.remove(q1[0])
    str = " "
    query = str.join(q1)
    if query == "":
        # If no query string is mentioned
        message.reply_sticker(random.choice(STICKERS))
        message.reply_text(
        text = f"""**Your Query should be in This format:** 

`/search <space> Name of the Anime you want to Search.`
For ex: /search one piece
""", parse_mode="markdown")
    else:
        url = f"https://gogoanime2.org/search{query}"
        session = HTMLSession()
        response = session.get(url)
        response_html = response.text
        soup = BeautifulSoup(response_html, 'html.parser')
        animes = soup.find("ul", {"class": "items"}).find_all("li")
        # print(animes)
        keyb = []
        for anime in animes:  # For every anime found
            tit = anime.a["title"]
            urll = anime.a["href"]
            r = urll.split('/')
            # aAnimes.append({"title" : anime.a["title"] , "link" : "https://www2.gogoanime.pe{}".format(anime.a["href"])})
            keyb.append([InlineKeyboardButton("{}".format(tit), callback_data="dt_{}".format(r[2]))])
        if keyb == []:
            # If returned list is empty, Send the following message.
            message.reply_text("❌ No results found, Check your Spelling and Search Again...")
        else:
            rep = InlineKeyboardMarkup(keyb)
            message.reply_text(text=f"Here is Your Search Results for **{query}**", reply_markup=rep, parse_mode="markdown")


<filename>Anime_Downloader_Probot/anime_search.py<gh_stars>0
import random
from pyrogram import *
from pyrogram.types import *
from requests_html import HTMLSession
from bs4 import BeautifulSoup

# Searching anime by regex pattern "/search <space> Anime Name"

STICKERS = (
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "<KEY>",
    "CAACAgUAAxkBAAECXYpgtiiK60ASuhzn5HF1hqlCyeWYHQACYQUAAo8k-yU17VzPXRipPB8E",
    "CAACAgUAAxkBAAECXYxgtiieT0cYvIYTwqzAPPOi-x-IIgACYwUAAo8k-yVtsLZX7RZPZx8E",
)


def anime_search(client, message):
    q = message.text
    q1 = q.split()
    q1.remove(q1[0])
    str = " "
    query = str.join(q1)
    if query == "":
        # If no query string is mentioned
        message.reply_sticker(random.choice(STICKERS))
        message.reply_text(
        text = f"""**Your Query should be in This format:** 

`/search <space> Name of the Anime you want to Search.`
For ex: /search one piece
""", parse_mode="markdown")
    else:
        url = f"https://gogoanime2.org/search{query}"
        session = HTMLSession()
        response = session.get(url)
        response_html = response.text
        soup = BeautifulSoup(response_html, 'html.parser')
        animes = soup.find("ul", {"class": "items"}).find_all("li")
        # print(animes)
        keyb = []
        for anime in animes:  # For every anime found
            tit = anime.a["title"]
            urll = anime.a["href"]
            r = urll.split('/')
            # aAnimes.append({"title" : anime.a["title"] , "link" : "https://www2.gogoanime.pe{}".format(anime.a["href"])})
            keyb.append([InlineKeyboardButton("{}".format(tit), callback_data="dt_{}".format(r[2]))])
        if keyb == []:
            # If returned list is empty, Send the following message.
            message.reply_text("❌ No results found, Check your Spelling and Search Again...")
        else:
            rep = InlineKeyboardMarkup(keyb)
            message.reply_text(text=f"Here is Your Search Results for **{query}**", reply_markup=rep, parse_mode="markdown")


# Searching anime by regex pattern "/search <space> Anime Name" # If no query string is mentioned **Your Query should be in This format:**   `/search <space> Name of the Anime you want to Search.` For ex: /search one piece # print(animes) # For every anime found # aAnimes.append({"title" : anime.a["title"] , "link" : "https://www2.gogoanime.pe{}".format(anime.a["href"])}) # If returned list is empty, Send the following message.