-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-2.py
120 lines (74 loc) · 3.06 KB
/
test-2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
def ask_google(query):
# Search for query
query = query.replace(' ', '+')
driver.get('http://www.google.com/search?q=' + query)
# Get text from Google answer box
answer = driver.execute_script(
"return document.elementFromPoint(arguments[0], arguments[1]);",
350, 230).text
print(answer)
pip install webdriver-manager
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
ask_google("what is the weather in chennai")
######################################################
import wikipedia
from googlesearch import search
print(wikipedia.summary("door key",sentences=10))
query = "sql code -181"
for j in search(query, tld="com", stop=2):
result.append(j)
for i in range(0,2):
import webbrowser
webbrowser.open(result[i])
print('\n')
print('Bot: Welcome Madhu..,i am here to help you')
print('Bot: Type "Quit" to stop ')
import wikipedia
from googlesearch import search
while True:
#welcome block
ip = input('Madhu:')
#google block
if ('google' in ip) or ('Google' in ip):
print ('Bot: You are Now inside Google session:')
google = input('Bot: Please enter search word:')
if google == 'quit' or google == 'Quit':
print('Bot: Bye')
break;
result=[]
for i in search(google, tld="com", stop=2):
result.append(i)
print('Bot: Please check your default browser,if you are not satisfied with result try some different keyword')
for i in range(0,2):
import webbrowser
webbrowser.open(result[i])
#wikipedia block
elif ('wiki' in ip) or ('Wiki' in ip) or ('Wikipedia' in ip) or ('wikipedia' in ip):
print ('Bot: You are Now inside Wiki session:')
wiki = input('Bot: Please enter search word:')
if wiki == 'quit' or wiki == 'Quit':
print('Bot: Bye')
break;
print('Bot:'+ wikipedia.summary(wiki,sentences=10))
#translator
elif ('translate' in ip) or ('Translate' in ip):
from googletrans import Translator
translator = Translator()
tran = input('Bot: Please enter text to translate: ' )
lang = input('Bot: please enter destination language: ')
trans = translator.translate(tran,dest=lang)
print('Bot: '+trans.text)
#dictionary
elif ('dict' in ip) or ('Dict' in ip) or ('dictionary' in ip) or ('Dictionary' in ip):
from PyDictionary import PyDictionary
dictionary=PyDictionary()
find = input('Bot: Please enter the word: ')
print ('Bot: ',dictionary.meaning(find))
if ip == 'quit' or ip == 'Quit':
print('Bot: Bye')
break;
ip = input('Enter:')
if ('google' in ip) or ('Google' in ip):
print ('success')