Skip to content

Instantly share code, notes, and snippets.

@mohsinkhann12
Created November 28, 2024 09:32
Show Gist options
  • Save mohsinkhann12/68645cccddd3f2c7e958460917d70fb3 to your computer and use it in GitHub Desktop.
Save mohsinkhann12/68645cccddd3f2c7e958460917d70fb3 to your computer and use it in GitHub Desktop.
Test Gist for OpenGenus
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