Ejemplo n.º 1
0
def google(query, page_num=1):
    assert (page_num > 0
            )  # CHANGE SO YOU CAN CONCATENATE RESULT IF YOU WANT MORE PAGES
    search_args = (query, page_num)
    google_search = GoogleSearch()
    google_results = google_search.search(*search_args)
    return google_results['links']
Ejemplo n.º 2
0
async def gsearch(q_event):
    await q_event.edit("`Processing...`")
    match = q_event.text.split(" ")[1]
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(len(gresults["links"])):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await q_event.edit("**Search Query:**\n`" + match + "`\n\n**Results:**\n" +
                       msg,
                       link_preview=False)
Ejemplo n.º 3
0
async def gsearch(q_event):
    """ For .google command, do a Google search. """
    match = q_event.pattern_match.group(1)
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(10):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await q_event.edit("**Kata Kunci:**\n`" + match + "`\n\n**Hasil:**\n" +
                       msg,
                       link_preview=False)

    if BOTLOG:
        await q_event.client.send_message(
            BOTLOG_CHATID,
            "Hasil Search Google `" + match + "` Telah Berhasil Dijalankan",
        )
Ejemplo n.º 4
0
async def gsearch(q_event):
    """ For .google command, do a Google search. """
    await q_event.edit("""`Ruk Bsdk tera IP Ban karwata Hoon`""")
    reply = await q_event.get_reply_message()
    if q_event.pattern_match.group(1):
        url = q_event.pattern_match.group(1)
    elif reply is not None:
        url = reply.message
    else:
        return
    page = findall(r"page=\d+", url)
    try:
        page = page[0]
        page = page.replace("page=", "")
        url = url.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(url), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    i = 1

    for i in range(11):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"{i}. [{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break

    await q_event.edit(
        "**Search Query:**\n`" + url + "`\n\n**Results:**\n" + msg, link_preview=False
    )
Ejemplo n.º 5
0
async def gsearch(q_event):
    """ .google komutu için bir Google araması yapın. """
    match = q_event.pattern_match.group(1)
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(len(gresults["links"])):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"👉[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await q_event.edit("**Arama Sorgusu:**\n`" + match +
                       "`\n\n**Sonuçlar:**\n" + msg,
                       link_preview=False)
    if BOTLOG:
        await q_event.client.send_message(
            BOTLOG_CHATID,
            "Google Arama sorgusu `" + match + "` başarıyla yürütüldü",
        )
Ejemplo n.º 6
0
def mailmode(mailfile):

	with open(mailfile) as f:
	
		lines = f.readlines()
		for line in lines:
		
			query = "site:linkedin.com/in '%s'" % (str(line))
			search_args = (query, 1)
			gsearch = GoogleSearch()
			gresults = gsearch.search(*search_args)
			urls = gresults['links']
			titles = gresults['titles']
			
			i=0
			for title in titles:
				if "-" in title:
						
					details = str(title).split(" - ")
					link = urls[i]
					dinurl = link.split("=")
					
					print(details[0] + ", " + details[1])
					
					f = open(outfile, 'a')
					f.write("\n" + details[0] + "," + details[1] + "," + line.rstrip() + "," + dinurl[1])
					f.close()
					
					i+=1
Ejemplo n.º 7
0
 async def googlecmd(self, message):
     """Shows Google search results."""
     if len(utils.get_args_raw(message)) == 0:
         text = (await message.get_reply_message()).message
     else:
         text = utils.get_args_raw(message.message)
     if len(text) == 0:
         await message.edit(_("Unfortunately, I can't Google nothing."))
     # TODO: add ability to specify page number.
     search_args = (str(text), 1)
     gsearch = GoogleSearch()
     gresults = await gsearch.async_search(*search_args)
     msg = ""
     for i in range(len(gresults["titles"])):
         try:
             title = gresults["titles"][i]
             link = gresults["links"][i]
             desc = gresults["descriptions"][i]
             msg += f"<p><a href='{link}'>{title}</a></p>\
             \n<code>{desc}</code>\n\n"
         except IndexError:
             break
     if msg == "":
         await utils.answer(message, _(f"Could not find anything about <code>{text}</code> on Google."))
         return
     else:
         await utils.answer(message, _(f"These came back from a Google search for <code>{text}</code>:\
         \n\n{msg}"))
Ejemplo n.º 8
0
async def _(event):
    if event.fwd_from:
        return
    if event.is_group:
        if not (await is_register_admin(event.input_chat,
                                        event.message.sender_id)):
            await event.reply(
                " Hai.. You are not admin..  You can't use this command.. But you can use in my pm"
            )
            return
    # SHOW_DESCRIPTION = False
    catevent = await event.reply("`searching........`")
    match = event.pattern_match.group(1)
    page = re.findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(len(gresults["links"])):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"•[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await catevent.edit("**Search Query:**\n`" + match +
                        "`\n\n**Results:**\n" + msg,
                        link_preview=False)
Ejemplo n.º 9
0
async def gsearch(message: Message):
    await message.edit("Arıyorum ...")
    query = message.filtered_input_str
    flags = message.flags
    page = int(flags.get('-p', 1))
    limit = int(flags.get('-l', 5))
    if message.reply_to_message:
        query = message.reply_to_message.text
    if not query:
        await message.err(text="Google'a bir sorgu gönderin veya bir mesajı yanıtlayın!")
        return
    try:
        g_search = GoogleSearch()
        gresults = await g_search.async_search(query, page)
    except Exception as e:
        await message.err(text=e)
        return
    output = ""
    for i in range(limit):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            output += f"[{title}]({link})\n"
            output += f"`{desc}`\n\n"
        except IndexError:
            break
    output = f"**Google'da aradım:**\n`{query}`\n\n**Bulduklarım:**\n{output}"
    await message.edit_or_send_as_file(text=output, caption=query,
                                       disable_web_page_preview=True)
Ejemplo n.º 10
0
async def gsearch(q_event):
    """ .google  """
    match = q_event.pattern_match.group(1)
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(10):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await q_event.edit("**Axtarış sorğusu:**\n`" + match + "`\n\n**Nəticələr:**\n" +
                       msg,
                       link_preview=False)

    if BOTLOG:
        await q_event.client.send_message(
            BOTLOG_CHATID,
            match + "`sözcüyü uğurla Google'da axtarıldı!`",
        )
Ejemplo n.º 11
0
async def gsearch(message: Message):
    query = message.filtered_input_str
    await message.edit(f"**Googling** for `{query}` ...")
    flags = message.flags
    page = int(flags.get('-p', 1))
    limit = int(flags.get('-l', 5))
    if message.reply_to_message:
        query = message.reply_to_message.text
    if not query:
        await message.err("Give a query or reply to a message to google!")
        return
    try:
        g_search = GoogleSearch()
        gresults = await g_search.async_search(query, page)
    except Exception as e:
        await message.err(e)
        return
    output = ""
    for i in range(limit):
        try:
            title = gresults["titles"][i].replace("\n", " ")
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            output += f"[{title}]({link})\n"
            output += f"`{desc}`\n\n"
        except (IndexError, KeyError):
            break
    output = f"**Google Search:**\n`{query}`\n\n**Results:**\n{output}"
    await message.edit_or_send_as_file(text=output,
                                       caption=query,
                                       disable_web_page_preview=True)
Ejemplo n.º 12
0
async def gsearch(q_event):
    """ For .google command, do a Google search. """
    match = q_event.pattern_match.group(1)
    tele = await eor(q_event, "Searching for `{}`".format(match))
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    res = ""
    for i in range(len(gresults["links"])):
        try:
            teletitle = gresults["titles"][i]
            telelink = gresults["links"][i]
            teledescrp = gresults["descriptions"][i]
            res += f"[{teletitle}]({telelink})\n`{teledescrp}`\n\n"
        except IndexError:
            break
    await tele.edit(
        "**GᴏᴏɢʟᴇSᴇᴀʀᴄʜ**\n__Qᴜᴇʀʏ:__\n `{}` \n\n**Rᴇsᴜʟᴛs:**\n {}".format(
            match, res),
        link_preview=False,
    )
Ejemplo n.º 13
0
async def inline_id_handler(event: events.InlineQuery.Event):
    event.builder
    results = []
    match = event.pattern_match.group(1)
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1

    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    for i in range(len(gresults["links"])):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            okiknow = f"**GOOGLE - SEARCH** \n[{title}]({link})\n\n`{desc}`"
            results.append(await event.builder.article(
                title=title,
                description=desc,
                text=okiknow,
                buttons=[
                    Button.switch_inline("Search Again",
                                         query="google ",
                                         same_peer=True)
                ],
            ))
        except IndexError:
            break
    await event.answer(results)
Ejemplo n.º 14
0
async def gsearch(q_event):
    """ .google komutu ile basit Google aramaları gerçekleştirilebilir """
    match = q_event.pattern_match.group(1)
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(10):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await q_event.edit("**Arama Sorgusu:**\n`" + match +
                       "`\n\n**Sonuçlar:**\n" + msg,
                       link_preview=False)

    if BOTLOG:
        await q_event.client.send_message(
            BOTLOG_CHATID,
            match + "`sözcüğü başarıyla Google'da aratıldı!`",
        )
Ejemplo n.º 15
0
async def _(event):
    if event.fwd_from:
        return

    webevent = await event.reply("searching........")
    match = event.pattern_match.group(1)
    page = re.findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(len(gresults["links"])):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"❍[{title}]({link})\n**{desc}**\n\n"
        except IndexError:
            break
    await webevent.edit("**Search Query:**\n`" + match +
                        "`\n\n**Results:**\n" + msg,
                        link_preview=False)
Ejemplo n.º 16
0
async def gsearch(q_event):
    """For .google command, do a Google search."""
    match = q_event.pattern_match.group(1)
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    try:
        search_args = (str(match), int(page))
        gsearch = GoogleSearch()
        gresults = await gsearch.async_search(*search_args)
        msg = ""
        for i in range(7):
            try:
                title = gresults["titles"][i]
                link = gresults["links"][i]
                desc = gresults["descriptions"][i]
                msg += f"[{title}]({link})\n`{desc}`\n\n"
            except IndexError:
                break
    except BaseException as g_e:
        return await q_event.edit(f"**Kesalahan :** `{g_e}`")
    await q_event.edit("**Kueri Pencarian :**\n`" + match +
                       "`\n\n**Hasil :**\n" + msg,
                       link_preview=False)

    if BOTLOG:
        await q_event.client.send_message(
            BOTLOG_CHATID,
            "Permintaan pencarian Google `" + match + "` berhasil dilakukan.",
        )
Ejemplo n.º 17
0
async def gsearch(q_event):
    if q_event.fwd_from:
        return
    """ For .google command, do a Google search. """
    match = q_event.pattern_match.group(1)
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(len(gresults["links"])):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await q_event.edit("**Search Query:**\n`" + match + "`\n\n**Results:**\n" +
                       msg,
                       link_preview=False)
Ejemplo n.º 18
0
async def gsearch(q_event):
    match = q_event.pattern_match.group(1)
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(10):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await q_event.edit(
        "**Search Query:**\n`" + match + "`\n\n**Results:**\n" + msg, link_preview=False
    )

    if BOTLOG:
        await q_event.client.send_message(
            BOTLOG_CHATID,
            "Google Search query `" + match + "` was executed successfully",
        )
Ejemplo n.º 19
0
async def gsearch(q_event):
    """ Para o comando .google, faz uma pesquisa no Google. """
    match = q_event.pattern_match.group(1)
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(10):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await q_event.edit(
        "**Consulta de Pesquisa:**\n`" + match + "`\n\n**Resultados:**\n" +
        msg,
        link_preview=False,
    )

    if BOTLOG:
        await q_event.client.send_message(
            BOTLOG_CHATID,
            "Consulta de pesquisa do Google `" + match +
            "` foi executado com sucesso",
        )
Ejemplo n.º 20
0
def compmode(query):

	pagec = 1
	
	while pagec<= numr:

		search_args = (query, pagec)
		gsearch = GoogleSearch()
		gresults = gsearch.search(*search_args)
		urls = gresults['links']
		titles = gresults['titles']

		i=0
		for line in titles:
			if "-" in line:
					
				details = str(line).split(" - ")
				link = urls[i]
				dinurl = link.split("=")
				
				print(details[0] + ", " + details[1])
				
				f = open(outfile, 'a')
				f.write("\n" + details[0] + "," + details[1] + "," + dinurl[1])
				f.close()
				
				i+=1

		pagec += 1
Ejemplo n.º 21
0
async def google(event):
    inp = event.pattern_match.group(1)
    if not inp:
        return await event.edit("`Give something to search..`")
    x = await eor(event, get_string("com_2"))
    gs = GoogleSearch()
    try:
        res = await gs.async_search(f"{inp}", cache=False)
    except GoglError as e:
        return await eor(event, str(e))
    out = ""
    try:
        for i in range(len(res["links"])):
            text = res["titles"][i]
            url = res["links"][i]
            des = res["descriptions"][i]
            out += f" 👉🏻  [{text}]({url})\n`{des}`\n\n"
    except TypeError:
        return await eod(event, f"`Can't find anything about {inp}`")
    omk = f"**Google Search Query:**\n`{inp}`\n\n**Results:**\n{out}"
    opn = []
    for bkl in range(0, len(omk), 4095):
        opn.append(omk[bkl:bkl + 4095])
    for bc in opn:
        await event.respond(bc, link_preview=False)
    await x.delete()
    opn.clear()
Ejemplo n.º 22
0
async def gsearch(q_event):
    catevent = await edit_or_reply(q_event, "`جـاري البـحث... `")
    match = q_event.pattern_match.group(1)
    page = re.findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(len(gresults["links"])):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"👉[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await catevent.edit("**استعلام بحث :**\n`" + تطابق + "`\n\n**نتائج:**\n" +
                        msg,
                        link_preview=False)
    if BOTLOG:
        await q_event.client.send_message(
            BOTLOG_CHATID,
            "استعلام بحث Google `" + تطابق + "` تم تنفيذه بنجاح",
        )
Ejemplo n.º 23
0
 async def googlecmd(self, message):
     """Shows Google search results."""
     text = utils.get_args_raw(message.message)
     if not text:
         text = (await message.get_reply_message()).message
     if not text:
         await utils.answer(message, self.strings["no_term"])
         return
     # TODO: add ability to specify page number.
     gsearch = GoogleSearch()
     gresults = await gsearch.async_search(text, 1)
     if not gresults:
         await utils.answer(message,
                            self.strings["no_results"].format(text))
         return
     msg = ""
     results = zip(gresults["titles"], gresults["links"],
                   gresults["descriptions"])
     for result in results:
         msg += self.strings["result"].format(utils.escape_html(result[0]),
                                              utils.escape_html(result[1]),
                                              utils.escape_html(result[2]))
     await utils.answer(
         message,
         self.strings["results"].format(utils.escape_html(text)) + msg)
Ejemplo n.º 24
0
async def gsearch(q_event):
    """ For .google command, do a Google search. """
    if environ.get("isSuspended") == "True":
        return
    reply_message = await q_event.get_reply_message()
    query = q_event.pattern_match.group(1)
    opts, query = parse_arguments(query, ['page', 'limit'])

    page = opts.get('page', 1)
    gsearch = GoogleSearch()

    query = query or reply_message.text
    gresults = gsearch.search(query, 1)

    msg = ""
    limit = opts.get('limit', 5)
    for i in range(limit):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"[{title}]({link}) \n"
            msg += f"`{desc}`\n\n"
        except IndexError:
            break
    await q_event.edit("**Search Query:**\n`" + query + "`\n\n**Results:**\n" +
                       msg,
                       link_preview=False)
    if BOTLOG:
        await q_event.client.send_message(
            BOTLOG_CHATID,
            "Google Search query `" + query + "` was executed successfully",
        )
Ejemplo n.º 25
0
async def gsearch(q_event):
    sender = await q_event.get_sender() ; me = await q_event.client.get_me()
    if not sender.id == me.id:
        rkp = await q_event.reply("`processing...`")
    else:
    	rkp = await q_event.edit("`processing...`")   
    match = q_event.pattern_match.group(1)
    page = findall(r"page=\d+", match)
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(10):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await rkp.edit("**Search Query:**\n`" + match + "`\n\n**Results:**\n" +
                       msg,
                       link_preview=False)
Ejemplo n.º 26
0
async def gsearch(q_event):
    try:
        match = q_event.text.split(" ", maxsplit=1)[1]
    except IndexError:
        kkkk = q_event.builder.article(
            title="Search Something",
            thumb=wb(gugirl, 0, "image/jpeg", []),
            text="**Gᴏᴏɢʟᴇ Sᴇᴀʀᴄʜ**\n\nYou didn't search anything",
            buttons=Button.switch_inline("Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
                                         query="go ",
                                         same_peer=True),
        )
        await q_event.answer([kkkk])
    searcher = []
    page = findall(r"page=\d+", match)
    cache = False
    try:
        page = page[0]
        page = page.replace("page=", "")
        match = match.replace("page=" + page[0], "")
    except IndexError:
        page = 1
    search_args = (str(match), int(page), bool(cache))
    gsearch = GoogleSearch()
    gresults = await gsearch.async_search(*search_args)
    msg = ""
    for i in range(len(gresults["links"])):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"👉[{title}]({link})\n`{desc}`\n\n"
            searcher.append(
                await q_event.builder.article(
                    title=title,
                    description=desc,
                    thumb=wb(gugirl, 0, "image/jpeg", []),
                    text=
                    f"**Gᴏᴏɢʟᴇ Sᴇᴀʀᴄʜ**\n\n**••Tɪᴛʟᴇ••**\n`{title}`\n\n**••Dᴇsᴄʀɪᴘᴛɪᴏɴ••**\n`{desc}`",
                    link_preview=False,
                    buttons=[
                        [Button.url("Lɪɴᴋ", url=f"{link}")],
                        [
                            Button.switch_inline(
                                "Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
                                query="go ",
                                same_peer=True,
                            ),
                            Button.switch_inline(
                                "Sʜᴀʀᴇ",
                                query=f"go {match}",
                                same_peer=False,
                            ),
                        ],
                    ],
                ), )
        except IndexError:
            break
    await q_event.answer(searcher)
Ejemplo n.º 27
0
 async def googlexxx(message):
     await message.edit("<i>Searching..</i>")
     search_args = (utils.get_arg(message), 1)
     gsearch = GoogleSearch()
     gresults = await gsearch.async_search(*search_args)
     text = ""
     try:
         for i in range(6):
             text += f"<b>◍ {gresults['titles'][i].upper()} :</b>\n\n<i>{gresults['descriptions'][i]}</i>\n\n{gresults['links'][i]}\n\n"
     except IndexError:
         pass
     await message.edit(text, link_preview=False)
Ejemplo n.º 28
0
async def gsearch(q_event):
    man = await edit_or_reply(q_event, "`Processing...`")
    match = q_event.pattern_match.group(1)
    page = re.findall(r"-p\d+", match)
    lim = re.findall(r"-l\d+", match)
    try:
        page = page[0]
        page = page.replace("-p", "")
        match = match.replace("-p" + page, "")
    except IndexError:
        page = 1
    try:
        lim = lim[0]
        lim = lim.replace("-l", "")
        match = match.replace("-l" + lim, "")
        lim = int(lim)
        if lim <= 0:
            lim = int(5)
    except IndexError:
        lim = 5
    smatch = match.replace(" ", "+")
    search_args = (str(smatch), int(page))
    gsearch = GoogleSearch()
    bsearch = BingSearch()
    ysearch = YahooSearch()
    try:
        gresults = await gsearch.async_search(*search_args)
    except NoResultsOrTrafficError:
        try:
            gresults = await bsearch.async_search(*search_args)
        except NoResultsOrTrafficError:
            try:
                gresults = await ysearch.async_search(*search_args)
            except Exception as e:
                return await edit_delete(man, f"**ERROR:**\n`{e}`", time=10)
    msg = ""
    for i in range(lim):
        if i > len(gresults["links"]):
            break
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"👉 [{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break
    await edit_or_reply(
        man,
        "**Keyword Google Search:**\n`" + match + "`\n\n**Results:**\n" + msg,
        link_preview=False,
        aslink=True,
        linktext=f"**Hasil Pencarian untuk Keyword** `{match}` **adalah** :",
    )
Ejemplo n.º 29
0
async def gsearch(event):
    """ For .google command, do a Google search. """

    if event.is_reply and not event.pattern_match.group(2):
        match = await event.get_reply_message()
        match = str(match.message)
    else:
        match = str(event.pattern_match.group(2))

    if not match:
        return await event.edit(
            "`Reply to a message or pass a query to search!`")

    await event.edit("`Processing...`")

    if event.pattern_match.group(1) != "":
        counter = int(event.pattern_match.group(1))
        if counter > 10:
            counter = int(10)
        if counter <= 0:
            counter = int(1)
    else:
        counter = int(3)

    search_args = (str(match), int(1))
    gsearch = GoogleSearch()

    try:
        gresults = await gsearch.async_search(*search_args)
    except Exception:
        return await event.edit(
            "`Error: Your query could not be found or it was flagged as unusual traffic.`"
        )
    msg = ""

    for i in range(counter):
        try:
            title = gresults["titles"][i]
            link = gresults["links"][i]
            desc = gresults["descriptions"][i]
            msg += f"[{title}]({link})\n`{desc}`\n\n"
        except IndexError:
            break

    await event.edit("**Search Query:**\n`" + match + "`\n\n**Results:**\n" +
                     msg,
                     link_preview=False)

    if BOTLOG:
        await event.client.send_message(
            BOTLOG_CHATID,
            "Google Search query` " + match + " `was executed successfully",
        )
Ejemplo n.º 30
0
async def inline_id_handler(q_event: events.InlineQuery.Event):
    builder = q_event.builder
    #match = q_event.pattern_match.group(1)

    match, shivam = q_event.pattern_match.group(1).split(";")
    if q_event.query.user_id == bot.uid:
        miraculous = []
        page = findall(r"page=\d+", match)
        try:
            page = page[0]
            page = page.replace("page=", "")
            match = match.replace("page=" + page[0], "")
        except IndexError:
            page = 1
        search_args = (str(match), int(page))
        gsearch = GoogleSearch()
        gresults = await gsearch.async_search(*search_args)
        #msg = ""
        for i in range(int(shivam)):
            try:
                title = gresults["titles"][i]
                link = gresults["links"][i]
                desc = gresults["descriptions"][i]
                #msg += f"[{title}]({link})\n`{desc}`\n\n"
                msg = f"[{title}]({link})\n`{desc}`\n\n"
            except IndexError:
                break
            miraculous.append(await q_event.builder.article(
                title=title,
                description=desc,
                text=msg,
                buttons=Button.switch_inline("Search Again",
                                             query="google ",
                                             same_peer=True)))
        await q_event.answer(miraculous)
    if not q_event.query.user_id == bot.uid:
        resultm = builder.article(
            title="me not your bot",
            description="Mind Your Business",
            text=
            "Hey U Must Use https://github.com/TeamExtremePro/ExtremeProUserbot ",
            buttons=[
                [
                    Button.switch_inline("Search Again",
                                         query="google ",
                                         same_peer=True)
                ],
            ],
        )
        await q_event.answer([resultm])
        return