Files
Ultroid-fork/plugins/gadgets.py
1Danish-00 386eff647c v0.0.9 18/07/2021
Co-authored-by: New-dev0 <New-dev0@users.noreply.github.com>
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: Amit Sharma <48654350+buddhhu@users.noreply.github.com>
Co-authored-by: sppidy <sppidy@users.noreply.github.com>
Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com>
Co-authored-by: divkix <divkix@users.noreply.github.com>
Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com>
Co-authored-by: Programming Error <error@notavailable.live>
2021-07-18 17:47:15 +05:30

51 lines
1.6 KiB
Python

#
# Ultroid - UserBot
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available -
• `{i}gadget <search query>`
Gadget Search from Telegram.
"""
import requests
from bs4 import BeautifulSoup as bs
from . import *
@ultroid_cmd(pattern="gadget ?(.*)")
async def mobs(e):
mat = e.pattern_match.group(1)
if not mat:
await eor(e, "Please Give a Mobile Name to look for.")
query = mat.replace(" ", "%20")
jwala = f"https://gadgets.ndtv.com/search?searchtext={query}"
c = requests.get(jwala).content
b = bs(c, "html.parser", from_encoding="utf-8")
bt = await eor(e, "`Processing...`")
try:
out = "**📱 Mobile / Gadgets Search**\n\n"
re = b.find_all("div", "rvw-imgbox")
li = re[0].findNext()["href"]
mg = re[0].findNext().findNext().findNext()
tit = mg["title"]
cont = requests.get(li).content
nu = bs(cont, "html.parser", from_encoding="utf-8")
req = nu.find_all("div", "_pdsd")
imu = nu.find_all("source", type="image/webp")[0]["srcset"].split("?")[0]
out += f"☑️ **[{tit}]({li})**\n\n"
for fp in req:
ty = fp.findNext()
out += f"- **{ty.text}** - `{ty.findNext().text}`\n"
out += "_"
await e.reply(out, file=imu)
if e.out:
await bt.delete()
except Exception as a:
print(a)
await eor(e, "No Results Found")