Example #1
0
 def online_testcase(self):
     """this test is intended to not run on every project test.
     If you want to run the test, you should specifically run this method.
     """
     google_search = GoogleSearch('essanpupil')
     google_search.start_search()
     for item in google_search.search_result:
         url = urlparse(item)
         if url.scheme is not None:
             self.assertIn('http', url.scheme)
         else:
             self.fail('Parsing failed!')
Example #2
0
def dork1_t():
 	count = 0
 	while True:
 		try:
			google_search = GoogleSearch('inurl: id='+str(count))
			google_search.start_search(max_page=1)
			print(Fore.GREEN + google_search.search_result[count]) # will print the url as list of string
			print  (' ')
			count += 1
		except IndexError:
			pass
		except KeyboardInterrupt:
			mainmenu()
Example #3
0
 async def google(self, ctx, *, query: str):
     search = GoogleSearch(query)
     search.start_search()
     result = search.search_result
     em = discord.Embed(color=0x00ff00, title=f'Google Search Results for: {query}')
     if result == []:
         em.description = "No results for this search term was found. :x:"
         return await ctx.send(embed=em)
     else:
         em.description = f"**Top Result:**\n{result[0]}\n\n**Other Results:**\n{result[1]}\n{result[2]}\n{result[3]}\n{result[4]}\n{result[5]}"
     em.set_author(name=f"Searched by: {ctx.author.name}", icon_url=ctx.author.avatar_url)
     lol = []
     for x in result:
         lol.append(f"{x}\n")
     page = Pages(ctx, entries=lol, per_page=5)
     await page.paginate()
Example #4
0
    def run(self, edit):
        """Run KristinitaLuckyLink for Google.

        Arguments:
            edit {str} -- edit text in Sublime Text
        """
        selection_text, selection_region = self.get_selection()
        print('KristinitaLuckyLink Google called')

        # [DEPRECATED] google module:
        #
        # Reason — bugs for:
        #
        # 1. Multiple results («Кристина Кива» query),
        # 2. No result («Python Google» query),
        # 3. News, not SERP («Carmelo Anthony» query),
        # 4. HTML metadata links («YAML» query).
        #
        # About google module:
        # http://archive.li/TaC8V
        # http://archive.li/59pbq
        #
        # from google import search
        # Add pause, because multiple results may appear
        # and user may be blocked
        # for final_google_link in search(
        #         selection_text, num=1, stop=1, pause=5.0):
        #     print(final_google_link)
        google_search = GoogleSearch(selection_text)
        google_search.start_search(max_page=1)
        final_google_link = google_search.search_result[0]
        markdown_google_link = '[' + selection_text + \
            ']' + '(' + final_google_link + ')'

        # Replace selected text to Markdown link
        self.replace_selection(edit, selection_region, markdown_google_link)
Example #5
0
if cmd == '1':
    os.system('clear')
    os.system('figlet Name Search')
    print("Enter The Name")
    name = input('dorkdox@dorkdox:~# ')
    os.system('clear')
    print("Searching.")
    os.system('clear')
    time.sleep(1)
    print("Searching..")
    os.system('clear')
    time.sleep(1)
    print("Results For " + name + "")
    os.system('clear')
    google_search = GoogleSearch("intext:" + name + "")
    google_search.start_search(
        max_page=1)  # prints first page of google resulrs
    symphanny = google_search.start_search
    for x in google_search.search_result:
        print(x)
    print()
    print(
        "If you want to follow any of these URLs, simply paste them into your browser!"
    )
    print()
    print("Have a good day!")
    sys.exit()

if cmd == '2':
    os.system('clear')
Example #6
0
def find_answer(path):
    settings.isNotSure = False
    settings.urls_searched = 0
    #---------------------OCR if path is image--------------------------
    if not isinstance(path, list):
        question_answers = get_question_answers(path)
    else:
        question_answers = path

    question = question_answers[0].lower()
    answer1 = question_answers[1].lower()
    answer2 = question_answers[2].lower()
    answer3 = question_answers[3].lower()

    #--------------Set up variables when called for the first time for one question---------------
    if settings.last_first_answer != answer1:
        settings.isNegative = False
        settings.isTermino = False
        settings.numbers_tried = 0
        settings.start_time = time.time()
        settings.last_first_answer = answer1
        settings.time_out = settings.first_time_out

#---------------------Process question-----------------------------------
    question = processQuestion(question)

    #---------------------Search Google-----------------------------------
    google_search = GoogleSearch(question)
    google_search.start_search(
        max_page=settings.google_pages_loaded)  # MAYBE 0 IS THE FIRST PAGE?
    urls = google_search.search_result
    if len(urls) == 0:
        print(
            "Either the question is corrupt or your IP address has been banned :("
        )
    #---------------------Find occurrences of answers in URL--------------------
    first_urls = urls[:settings.number_of_urls]
    urls_and_answers = []
    for url in first_urls:
        urls_and_answers.append([url, answer1, answer2, answer3, question])

    #get frequencies using processes
    pool = Pool(processes=settings.number_of_workers)
    all_frequencies = pool.map(getFrequencies, urls_and_answers)
    pool.terminate()

    #calculate additive frequencies
    sumed_frequencies = [0, 0, 0]
    for freq in all_frequencies:
        sumed_frequencies[0] += freq[0]
        sumed_frequencies[1] += freq[1]
        sumed_frequencies[2] += freq[2]
    debug(sumed_frequencies)

    #--------------------------------Print scores----------------------------
    winner = print_scores([question_answers[0], answer1, answer2, answer3],
                          sumed_frequencies)
    settings.numbers_tried = settings.numbers_tried + 1

    #-----------------------------Search again or return----------------------------
    #if not sucessful search again but this time including the answers in the question and taking a bit more time
    if settings.isNotSure and settings.numbers_tried < 2:
        debug("Searching with answers icluded")
        time_out = settings.second_time_out
        print("Try going into URLs with answers included in the search")
        winner = find_answer([
            question_answers[0] + " " + answer1 + " " + answer2 + " " +
            answer3, answer1, answer2, answer3
        ])
    else:
        debug("--- querrying time:  %s seconds ---" %
              (time.time() - settings.start_time))

    return winner