Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ChatBotGroup/GoogleSearch.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23 lines (23 sloc)
1.12 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bs4 # This is required to include bs4 module | |
import requests # This is required to include request module | |
conversation_words = ["No", "no" "Nah", "nah", "No, i don't", "no, i don't"] | |
conversation_words1 = ["Yea", "yea", "Yeah", "yeah", "Yes", "yes", "Yes, i like", "yes, i like"] | |
bye = input("Bye the way, do you like our conversation? ") | |
if bye in conversation_words: | |
print("Okey, i'm gonna leave you alone!") | |
elif bye in conversation_words1: | |
print("Thank'ya, same here") | |
search = input("Do you want to search for something? Yes/No ") #https://www.youtube.com/watch?v=dyUhGZ6iNTc | |
if search == "Yes": | |
search1 = input("What do you want to search for? Write without spaces! ") | |
sus_adress = 'https://google.com/search?q=' + (search1) | |
result = requests.get(sus_adress) | |
result1 = bs4.BeautifulSoup(result.text, "html.parser") | |
link1 = result1.select('.r a') | |
link2 = min(2, len(link1)) | |
print("So the most popular information is - ") | |
for i in range(link2): | |
m = sus_adress + link1[i].get('href') | |
print(m[35+len(search1):-1]) | |
else: | |
print("Bye") |