Esempio n. 1
0
async def gsearch(q_event):
    """ For .google command, do a Google search. """
    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, page)

    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",
        )
Esempio n. 2
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']
Esempio 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 = gsearch.search(*search_args)
    msg = ""
    for i in range(10):
        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`" + 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",
        )
Esempio n. 4
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
Esempio n. 5
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
Esempio n. 6
0
def main(search_query, numRes):
    page_num = 1
    query = (search_query)
    result_count = 1
    file = open('data.txt', 'a')
    google = GoogleSearch()
    res = google.search(query, page_num)

    while 1:
        for i in range(0, 10):
            result_count += 1
            file.write('tilte -' + res['titles'][i] + '\n' + 'link -' +
                       res['links'][i] + '\n' + 'Description -' +
                       res['descriptions'][i] + '\n')
        if result_count < numRes:
            page_num += 1
            res = google.search(query, page_num)
        else:
            break
Esempio n. 7
0
def compmodeusernames(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("=")
				
				# usernames
				fullname = str(details[0]).split()
				name = fullname[0]
				surname = fullname[1]
				# 1 = NameSurname
				userone = name + surname
				# 2 = Name.Surname
				usertwo = name + "." + surname
				# 3 = NSurname
				userthree = name[0] + surname
				# 4 = NameS
				userfour = name + surname[0]
				# 5 = N.Surname
				userfive = name[0] + "." + surname
				
				print(details[0] + ", " + details[1])
				
				f = open(outfile, 'a')
				f.write("\n" + details[0] + "," + details[1] + "," + dinurl[1] + "," + userone + "," + usertwo + "," + userthree + "," + userfour + "," + userfive)
				f.close()
				
				i+=1

		pagec += 1
Esempio n. 8
0
def mailmodeusernames(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("=")
					
					# usernames
					fullname = str(details[0]).split()
					name = fullname[0]
					surname = fullname[1]
					# 1 = NameSurname
					userone = name + surname
					# 2 = Name.Surname
					usertwo = name + "." + surname
					# 3 = NSurname
					userthree = name[0] + surname
					# 4 = NameS
					userfour = name + surname[0]
					# 5 = N.Surname
					userfive = name[0] + "." + surname
					
					print(details[0] + ", " + details[1])
					
					f = open(outfile, 'a')
					f.write("\n" + details[0] + "," + details[1] + "," + line.rstrip() + "," + dinurl[1] + "," + userone + "," + usertwo + "," + userthree + "," + userfour + "," + userfive)
					f.close()
					
					i+=1
Esempio n. 9
0
async def gsearch(message: Message):
    await message.edit("Processing ...")

    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="Give a query or reply to a message to google!")
        return

    try:
        g_search = GoogleSearch()
        gresults = g_search.search(query, page)

    except Exception as e:
        await message.err(text=e, log=True)
        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 Search:**\n`{query}`\n\n**Results:**\n{output}"

    await message.edit_or_send_as_file(text=output,
                                       caption=query,
                                       disable_web_page_preview=True,
                                       log=True)
Esempio n. 10
0
def google(update, context):
    message = update.effective_message
    query = message.text.strip().split(" ", 1)
    try:
        gsearch = GoogleSearch()
        gresults = gsearch.search(query)
    except Exception as excp:
        message.reply_text(f"Search failed, Error: {excp}")
        return
    output = ""
    for i in range(5):
        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}"
    message.reply_text(output, parse_mode="Markdown")
Esempio n. 11
0
def google(query):
    search_args = (query, 1)
    gsearch = GoogleSearch()
    gresults = gsearch.search(*search_args)
    for every in gresults:
        print(every)
Esempio n. 12
0
import search_engine_parser
from search_engine_parser import YahooSearch, GoogleSearch, BingSearch, AolSearch, BaiduSearch, DuckDuckGoSearch

search = input('Enter your search query: ')

search_args = (search, 1)
gsearch = GoogleSearch()
ysearch = YahooSearch()
bsearch = BingSearch()
asearch = AolSearch()
b2search = BaiduSearch()
dsearch = DuckDuckGoSearch()

gresults = gsearch.search(*search_args)
yresults = ysearch.search(*search_args)
bresults = bsearch.search(*search_args)
aresults = asearch.search(*search_args)
b2results = b2search.search(*search_args)
dresults = dsearch.search(*search_args)

for i in range(10):
    print(gresults["titles"][i])
    print(gresults["links"][i])
    print(gresults["descriptions"][i])

    print(yresults["titles"][i])
    print(yresults["links"][i])
    print(yresults["descriptions"][i])

    print(dresults["titles"][i])
    print(dresults["links"][i])