Created
November 28, 2024 09:36
-
-
Save mohsinkhann12/2407595b4262a619b7b59bd546393144 to your computer and use it in GitHub Desktop.
Test Gist for OpenGenus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from shivu.modules.helpers.google import get_search_results | |
from pyrogram import Client, filters | |
from pyrogram.enums import ParseMode | |
from shivu import LOGGER | |
@Client.on_message(filters.command(["google","g"])) | |
async def google(client, message): | |
try: | |
query= message.text.split(None,1)[1] | |
except: | |
return await message.reply("Input query for search 🔍") | |
results = get_search_results(query) | |
if results: | |
msg = f"<b>Google Search results: {query}</b> | |
" | |
index = 1 | |
for result in results: | |
title = result["title"] | |
link = result["link"] | |
msg += f"{index}) <a href={link}>{title}</a> | |
" | |
index += 1 | |
await message.reply_text(msg, disable_web_page_preview=True, parse_mode=ParseMode.HTML) | |
else: | |
await message.reply_text("No results found.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment