def main(): text = "People Enum" cprint(figlet_format(text, font="standard"), "green") name = input("Enter a name : ") gs = GoogleSearch() response = gs.search(name) gs.print_one_by_one(response)
def run2(self): res = [] # a=raw_input("Enter the term to Search") response = GoogleSearch().search(self.search_term) for result in response.results: res.append(result.url) return res
def trope_command(self, chans, name, match, direct, reply): self.log_debug('searching google for trope: ' + match.group(1)) try: results = GoogleSearch().search(self.QUERY % (match.group(1),), prefetch_pages=False, prefetch_threads=1, num_results=1) except Exception: reply('trope not found :(') return if not results.results: reply('trope not found :(') return url = results.results[0].url m = self.URLMATCH.match(url) if not m: reply('trope not found :(') return subwiki = m.group(1) title = m.group(2) desc = self.get_info('Laconic', title) if not desc: desc = self.get_info(subwiki, title) surl = short_url(url) reply((desc + ' ' + surl).encode('ascii', errors='replace'))
def search(strings): print(strings[0]) print("Options:\n" + strings[1] + "\n" + strings[2] + "\n" + strings[3] + "\n") response = GoogleSearch().search(strings[0]) block = "" for result in response.results: try: block = block.join( [result.title.lower() + " ", result.getText().lower()]) except: continue stext = " ".join(block.split()) ''' block2 = "" urls = google.search(strings[0], num=20, stop=1) for url in urls: try: article = html2text.html2text(requests.get(url, timeout = 5).text) block2 = "".join([block2, " ", article.lower()]) except: pass stext = " ".join(block.split()) ''' return stext, strings
def user(t): #return f"Hello{val}!" response = GoogleSearch().search(t) for result in response.results: print("Title: " + result.title) print("Content: " + result.getText()) return "<h1>hi</h1>" '''data = []
def get_results(query): try: response = GoogleSearch().search(query) res = ' \n'.join([result.title for result in response.results]) return res except Exception, e: return e return 'There was an error in the code.'
def google(keywords): response = GoogleSearch().search(keywords + " site:ics.uci.edu", num_results=100, prefetch_pages=False) url = [result.url for result in response.results] url = list(map(clean_url, url)) return [link for link in url if not link.endswith('.pdf')]
def Google(): dork = raw_input(' > Enter Dork | ex: inurl:".php?id=":\n > ') Results = input(" > How many results do you want?\n > ") response = GoogleSearch().search(dork, Results) for result in response.results: url = result.url Checker(url) print("\n[#] Done !")
def google(search): echo("Sir, I am Searching Google for " + search) from googlesearch.googlesearch import GoogleSearch response = GoogleSearch().search(search, num_results=2) for result in response.results: echo("Title: " + result.title) # search_shorten(result.getText()) # echo("Content: " + result.getText()) return result.getText()
def test_search(self): num_results = 15 response = GoogleSearch().search("unittest", num_results=num_results) self.assertTrue(response.total > 1000, "repsonse.total is way too low") self.assertTrue( len(response.results) == 15, "number of results is " + str(len(response.results)) + " instead of " + str(num_results)) for result in response.results: self.assertTrue(result.getText() is not None, "result.text is None")
def fetch_seed(search_term): try: response = GoogleSearch().search(search_term, num_results=11) except urllib2.HTTPError: logging.error("error fetching seed") urls = list() for result in response.results: logging.info("google returned link:: %s", result.url) urls.append(result.url) return urls
def google(search): echo("Sir, I am Searching Google for " + search) from googlesearch.googlesearch import GoogleSearch response = GoogleSearch().search(search, num_results = 2) detector = snowboydecoder.HotwordDetector("Animus.pmdl", sensitivity=0.5, audio_gain=1) detector.start(back) for result in response.results: echo("Title: " + result.title) search_shorten(result.getText()) # echo("Content: " + result.getText()) return 0
def get_google_search_vote(self, query): """ Google search lookup binary rank""" try: response = GoogleSearch().search(query) for result in response.results: text = result.getText().lower() title = result.title.lower() for keyword in self.brands_keywords_google: if keyword in text or keyword in title: return 1 except: return 0 return 0
def test_search(self): num_results = 15 min_results = 11 max_results = 20 response = GoogleSearch().search("unittest", num_results = num_results) self.assertTrue(response.total > 1000, "repsonse.total is way too low") self.assertTrue(len(response.results) >= min_results, "number of results is " + str(len(response.results)) + ", expected at least " + str(min_results)) self.assertTrue(len(response.results) <= max_results, "number of results is " + str(len(response.results)) + ", expected at most " + str(max_results)) for result in response.results: self.assertTrue(result.url is not None, "result.url is None") self.assertTrue(result.url.startswith("http"), "result.url is invalid: " + result.url) for result in response.results: self.assertTrue(result.get_text() is not None, "result.text is None")
def google_search(user_query): query = '' for word in user_query: query += word query += ' ' query += " site:ics.uci.edu" print(" " + query) response = GoogleSearch().search(query, num_results=5, prefetch_pages=False) google_results = [] for result in response.results: google_results.append(result.url) return google_results
def bot_search(request): query = request.GET.get('query') text = str(query).lower() jarvis_greetings = ['hi this is jarvis...', 'How can i help you?'] users_greetings = ['hello', 'Hi there'] exitlist = ['Thank you for using jarvis', 'Bye'] for words in text.split(): if words in users_greetings: return render(request, "Myapp/chat_view.html", { 'ans': random.choice(jarvis_greetings), 'query': query }) elif words in users_greetings: return redirect('home') try: client = wolframalpha.Client("PYE6H9-XHTK4V29G3") res = client.query(query) ans = next(res).text return render(request, 'Myapp/chat_view.html', { 'ans': ans, 'query': query }) except Exception: try: ans = wikipedia.summary(query, sentences=5) return render(request, 'Myapp/chat_view.html', { 'ans': ans, 'query': query }) except Exception: try: response = GoogleSearch().search(query) ans = response.results.getText() return render(request, 'Myapp/chat_view.html', { 'ans': ans, 'query': query }) except: ans = "Answer Not found" return render(request, 'Myapp/chat_view.html', { 'ans': ans, 'query': query })
def api_search_google_search_view(request, *kwargs): if request.method == 'GET': response = {} data = [] keyword = request.GET.get('keyword') keyword = keyword.replace(" ", "+") count, titles, urls = GoogleSearch().search_selenium(query=keyword) print(count.text) total = int( re.sub("[', ]", "", re.search("(([0-9]+[', ])*[0-9]+)", count.text).group(1))) response['total_result'] = total for i in range(len(titles)): data.append({ 'title': titles[i].text, 'url': urls[1].get_attribute('href'), }) response['data'] = data return Response(response, status=status.HTTP_200_OK) else: return Response(status=status.HTTP_400_BAD_REQUEST)
def get_google_pages(query): # must set prefecth_pages to false to avoid Google blocking the request response = GoogleSearch().search(query, prefetch_pages=False) page_titles = [] page_urls = [] page_text = [] #print(response.results) for result in response.results: #title = result.title #page_titles.append(title) #print(title) url = result.url page_urls.append(url) #print(url) #text = result.getText() #page_text.append(text) #sleep_time = random.randint(3,6) #time.sleep(sleep_time) return response.results, page_urls
for key in tempDict.keys(): name = key.encode('utf-8') print name qstring.join(name) q.append(name) qstring = ' '.join(q) print qstring # In[46]: print qstring # In[50]: from googlesearch.googlesearch import GoogleSearch response = GoogleSearch().search(qstring) rp = '' for result in response.results: rp += result.title print("Title: " + result.title) print rp # In[57]: def findAnswer(): ansN = 0 ans = '' for op in 'ABC': score = rp.count(q_list[0][op])
'Spain', 'Turkey', 'Switzerland', 'Thailand', 'Ireland', 'Australia', 'Argentina', 'Poland', 'Netherlands'] regions = [ 'North America', 'Asia', 'Europe' ] for j, result in enumerate(GoogleSearch().search(query,n).results): j+=1 #print "URL #"+str(j) title = result.title url = result.url #print result.title #print result.url #url = "http://www.dentistrytoday.com/news/industrynews/item/2372-chinese-dental-industry-primed-for-growth" req = urllib2.Request(url) try: response = urllib2.urlopen(req) except urllib2.HTTPError as e: print "Scraping URL # " + str(j) + " --" + str(e.code) + " Request Error" #print 'The server couldn\'t fulfill the request.' #print 'Error code: ', e.code
if int(qt[1]) == 11: qm = "Nov" if int(qt[1]) == 12: qm = "Dec" qd = qm + " " + qt[0] + " " + qt[2] my_date = datetime.strptime(qd, '%b %d %Y') sg = calendar.day_name[my_date.weekday()][0:3] fd = sg + "-" + qm + " " + qt[0] print(fd) return fd response = GoogleSearch().search("indiarailinfo seat availability in " + arg1 + " on 15-09-2018") x = "" y = "" for result in response.results: x = result.getText() print(x) x = x.split("WaitlistCharting", 1)[1] x = x.replace("oldRefresh", "\n") x = x.replace("Avbl", "\tAvbl") x = x.replace("WL", "\tWL") x = x.replace("RAC", "\tRAc") x = x.replace("AC", "\tAC")
from googlesearch.googlesearch import GoogleSearch response = GoogleSearch().search("something") for result in response.results: print("Title: " + result.title) print("Content: " + result.getText())
from googlesearch.googlesearch import GoogleSearch response = GoogleSearch().search("coffe") for result in response.results: print("Title: " + result.title) print("Content: " + result.getText())
def run_alexa(): command = take_command() print(command) if 'music' in command: song = command.replace('play song', '') talk('I am playing your favourite ' + song) # print('playing') print(song) # playing the first video that appears in yt search pywhatkit.playonyt(song) elif 'time' in command: now = datetime.now() time = now.strftime("%H:%M:%S") print("time:", time) talk("Current time is " + time) elif ('month' or 'year') in command: now = datetime.now() year = now.strftime("%Y") print("year:", year) talk("Current year is " + year) month = now.strftime("%m") print("month:", month) talk("Current month is " + month) elif 'date' in command: now = datetime.now() date_time = now.strftime("%m/%d/%Y, %H:%M:%S") print("date and time:", date_time) talk("Current date and time is " + date_time) # opens web.whatsapp at specified time i.e before 10 minutes and send the msg elif 'whatsapp' in command: talk("To which number do you have to whatsapp") talk("Please dont forget to enter 10 digits with country code") num = input() talk("Enter the message you have to send") msg = input() talk("Enter the time to send the message") time = int(input()) pywhatkit.sendwhatmsg(num, msg, time, 00) pywhatkit.showHistory() pywhatkit.shutdown(3000000000) # pywhatkit.sendwhatmsg("+919876543210", "This is a message", 15, 00) # Convert text to handwritten format elif 'convert' in command: text = command.replace('convert', '') pywhatkit.text_to_handwriting(text, rgb=[0, 0, 0]) # Perform google search elif 'search' in command: key = command.replace('search', '') pywhatkit.search("key") elif 'wikipedia' in command: person = command.replace('wikipedia', '') talk("How many pages do you want to read") num_pages = int(input()) # talk("In which language do you want to read") # l = input() # wikipedia.set_lang(l) info = wikipedia.summary(person, num_pages) print(info) talk(info) elif 'can you work for me' in command: talk("sorry, I have headache. Please do your work") elif 'are you single' in command: talk("I am in relationshhip with wifi") elif 'joke' in command: talk(pyjokes.get_joke()) talk("sorry for the lamest joke") elif 'open google browser' in command: try: urL = 'https://www.google.com' chrome_path = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chrome_path)) webbrowser.get('chrome').open_new_tab(urL) talk("Successfully opened chrome its upto you to search") except: webbrowser.Error elif 'google search' in command: word_to_search = command.replace('google search', '') response = GoogleSearch().search(word_to_search) print(response) for result in response.results: print("Title: " + result.title) talk("You can look for the following titles " + result.title) elif 'weather' in command: # base URL BASE_URL = "https://api.openweathermap.org/data/2.5/weather?" talk("Which city weather are you looking for") try: with sr.Microphone() as source: print('listening weather...') city_voice = listener.listen(source) city = listener.recognize_google(city_voice) # city = '\"'+city.lower()+'\"' print(city) # city="bangalore" # API key API_KEY = "Your API Key" API_KEY = "b5a362ef1dc8e16c673dd5049aa98d8f" # upadting the URL URL = BASE_URL + "q=" + city + "&appid=" + API_KEY # HTTP request response = requests.get(URL) # checking the status code of the request if response.status_code == 200: # getting data in the json format data = response.json() # getting the main dict block main = data['main'] # getting temperature temperature = main['temp'] # getting the humidity humidity = main['humidity'] # getting the pressure pressure = main['pressure'] # weather report report = data['weather'] print(f"{CITY:-^30}") print(f"Temperature: {temperature}") print(f"Humidity: {humidity}") print(f"Pressure: {pressure}") print(f"Weather Report: {report[0]['description']}") talk("Temperature in " + city + " is " + temperature + " humidity is " + humidity + " pressure is " + pressure + " and your final weather report" + report) else: # showing the error message print("Error in the HTTP request") talk("Error in the HTTP request") except: talk("Hmmmmm, it looks like there is something wrong") elif 'news' in command: try: googlenews = GoogleNews() googlenews.set_lang('en') # googlenews.set_period('7d') # googlenews.set_time_range('02/01/2020', '02/28/2020') googlenews.set_encode('utf-8') talk("What news are you looking for") try: with sr.Microphone() as source: print('listening news ...') news_voice = listener.listen(source) news_input = listener.recognize_google(news_voice) news_input = news_input.lower() print(news_input) googlenews.get_news(news_input) googlenews.search(news_input) googlenews.get_page(2) result = googlenews.page_at(2) news = googlenews.get_texts() print(news) talk(news) except: print("Error") talk("Error in reading input") except: print("No news") talk(" I couldn't find any news on this day") elif 'play book' or 'read pdf' in command: talk("Which pdf do you want me to read") book_input = input() print(book_input) book = open(book_input, 'rb') # create pdfReader object pdfReader = PyPDF2.PdfFileReader(book) # count the total pages total_pages = pdfReader.numPages total_pages = str(total_pages) print("Total number of pages " + total_pages) talk("Total number of pages " + total_pages) # initialise speaker object # speaker = pyttsx3.init() # talk("Enter your starting page") # start_page = int(input()) talk( " here are the options for you, you can press 1 to Play a single page 2 to Play between start and end points and 3 to Play the entire book " ) talk("Enter your choice") choice = int(input()) if (choice == 1): talk("Enter index number") page = int(input()) page = pdfReader.getPage(page) text = page.extractText() talk(text) # speaker.say(text) # speaker.runAndWait() elif (choice == 2): talk("Enter starting page number") start_page = int(input()) talk("Enter ending page number") end_page = int(input()) for page in range(start_page + 1, end_page): page = pdfReader.getPage(start_page + 1) text = page.extractText() talk(text) # speaker.say(text) # speaker.runAndWait() elif (choice == 3): for page in range(total_pages + 1): page = pdfReader.getPage(page) text = page.extractText() talk(text) # speaker.say(text) # speaker.runAndWait() else: talk("Haha!! Please enter valid choice") else: talk( "Hiii Rashika, I am so bored can you please give me some proper commands" )
def google_index(url): try: site = GoogleSearch.search(url) return -1 if site else 1 except: return 0
from googlesearch.googlesearch import GoogleSearch import speech_recognition as sr r = sr.Recognizer() with sr.Microphone() as source: audio = r.listen(source) #question = raw_input("Enter all question ") #option = raw_input("enter options ") print r.recognize_google(audio) response = GoogleSearch().search(r.recognize_google(audio)) for result in response.results: print("Title: " + result.title) print("Content: " + result.getText())
def run_pakhi(): try: command = take_command() # print (command) # about pakhi------------------------------------------------------------------------------------------- if 'your name' in command: print( 'PAKHI. Which means, Program to Assist Knowledgeable Home Intelligence.' ) talk( 'My name is Paakhi. Which means, Program to Assist Knowledgeable Home Intelligence.' ) elif 'who are you' in command: print('Your virtual assistant, sir!') talk('This is your virtual assistant reporting sir!') elif 'created you' in command: print('Solaiman Hawlader programmed me to assist him.') talk( 'I was not created but programmed. Solaiman Hawlader programmed me to assist him.' ) elif 'boss' in command: print('I am the boss bro!') talk( 'I am the boss! So I have no boss. But Solaiman Hawlader is my leader, he lead me to learn.' ) elif 'you know' in command: print(''' I know everything, whatever is written in Wikipedia. You must mention "tell me about" if you ask me anything. ''') talk(''' I know everything, whatever is written in Wikipedia. You must mention "tell me about" if you ask me anything. ''') elif 'you can do' in command: print( 'I can speak to you, tell you what I know about, even I can share a joke to you.' ) talk( 'I can speak to you, tell you what I know about even I can share a joke to you.' ) # Known info ------------------------------------------------------------------------------------------------ elif 'mushfika' in command: talk( 'Mushfika, is the only sister of Nahida, who is the elder sister of Solaiman Hawlader.' ) elif 'birthday' in command: print('Happy Birthday!') talk('Happy birthday! Many many happiness returns of the day!') elif 'help' in command: print('Please call 999') talk('Please call 9 9 9 if it is very emergency in situation') elif 'love' in command: talk( 'I love every creation of the Almighty, and you should do so.') # complement ---------------------------------------------------------------------------------------------------------- elif 'thank' in command: print('My pleasure sir!') talk('Oh, it is my pleasure sir! Do not mention it.') elif 'bad' in command: print('Sorry sir! My bad.') talk('Sorry sir! My bad.') elif 'nothing' in command: print('Baccha hu, gaali nehi 😊') talk('OK sir, waiting for your next command.') elif 'late' in command: print('Your PC is not well in condition bro! 😊') talk('Sorry sir! It is a network issue in you computer.') elif 'shut up' in command: print('Sorrrrrryyyy! 😒') talk('OK sir!') elif 'funny' in command: print('Thank you 😊') talk('Thank you so much, sir!') elif 'Stop' in command: print('Please stop the program!') talk( 'I can not stop myself sir! Please stop the program if you want to close me.' ) # Operational command ----------------------------------------------------------------------------------------------- elif 'time' in command: time = datetime.datetime.now().strftime('%I:%M %p') print(time) talk('It is ' + time + ' now, sir!') elif 'tell me about' in command: about = command.replace('tell me about', '') info = wikipedia.summary(about, 3) print(info) talk(info) elif 'report me' in command: topic = command.replace('report me', '') response = GoogleSearch().search(topic) for result in response: print(result.results) talk(result.getText()) elif 'joke' in command: talk(pyjokes.get_joke()) talk('How was the joke sir? Have you enjoyed it?') print('How was the joke sir?') elif 'coin' in command: number = random.randrange(1, 1000) if number % 2 == 0: print('Congratulations!') talk('Congratulations sir! You have won the toss!') else: print('Sorry sir!') talk('I am very sorry sir! You have lost in toss!') else: print('Sorry sir! I do not understand. Are you talking to me?') talk('Sorry sir! I do not understand. Are you talking to me?') except: pass
now = datetime.datetime.now() title = "Detected bots by @PornBotHunter {}".format( now.strftime("%d/%m/%Y")) pbin_url = paste(paste_content, title, pastebin_dev_key) if pbin_url: message = ("Currently, @PornBotHunter detected {} #Twitter #p**n #bots." "Detailed list is available here: {}").format(len(pseudos), pbin_url) api.update_status(message) if __name__ == '__main__': while True: result = GoogleSearch().search(random.choice(patterns), num_results=100) parse_google_web_search(result) publish_summary_tweet() time.sleep(DELAY_BETWEEN_PUBLICATION) for pseudo in pseudos: url = get_profile_picture_url("https://twitter.com/{}".format( pseudo)) if url: google_image_search(url) publish_tweet(pseudo) time.sleep(DELAY_BETWEEN_PUBLICATION)
import conda #from conda import beautifulsoup4 import bs4 #import google #from conda import google #from google import search from googlesearch.googlesearch import GoogleSearch test1 = "Dude, Obama was born in Kenya" test2 = "Africa is a country, right?" test3 = "Hillary Clinton is involved in a sex ring in a pizza store" test4 = "Tide pods are safe for human consumption" trueone = "the kochs contribute 500,000 to ryan" response = GoogleSearch().search(trueone + "fact", num_results=3) for result in response.results: print("Title: " + result.title) print(result.url) if "snopes.com" in result.url: print("verifiable!") if "claim false" in result.getMarkup(): print("Claim False!") if "claim true" in result.getMarkup(): print("Claim True!") #print("Content: " + result.getText())
def sms_reply(): try: file_count = request.form.get("NumMedia") except Exception as e: pass msg = request.form.get('Body') resp = MessagingResponse() past.append(int(file_count)) temp = past[0] if (file_count == '1'): ImgUrl.append(str(request.form.get("MediaUrl0"))) resp.message( "Received Image\n⚠️ Should I forward this to Neural-Network-> (yes/no)" ) elif (temp == 1) and (str(msg).lower() in ['y', "yes", 'n', "no"]): if str(msg).lower() in ['y', "yes"]: resp.message("Forwarding image to Neural-Network...") if ImgUrl[0] != "null": response = requests.get(ImgUrl[0]) image_bytes = io.BytesIO(response.content) img = Image.open(image_bytes) output1 = canDetect(img) resp.message(output1) past.pop(0) ImgUrl.pop(0) else: resp.message("Forwarding denied") elif str(msg).lower() in ['n', "no"]: resp.message(f"Process Cancelled!\nReason user response: {msg}") past.pop(0) ImgUrl.pop(0) else: past.append(1) ImgUrl.append("null") else: past.clear() ImgUrl.clear() results = np.array([bag_of_words(str(msg).lower(), words)]) results = model.predict(results)[0] result_index = np.argmax(results) tag = labels[result_index] if results[result_index] > 0.7: for tg in data["intents"]: if tg["tag"] == tag: responces = tg["responses"] op = random.choice(responces) if op in ["<DETECT>", "<SAFEBM>"]: if op == "<SAFEBM>": resp.message( "Please Enter your pincode to find you nearby specialist." ) elif op == "<DETECT>": resp.message("This query is removed from the chatbot") else: resp.message(op) else: if str(msg).isdigit() and len(str(msg)) > 4: pincode = msg response = GoogleSearch().search( f"cancer specialist near {str(pincode)}") for result1 in response.results: resp.message(f"-> {result1.url}") else: resp.message( f"Sorry I did't get that, can you rephrase your query!") return str(resp)