-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathweb_access.py
44 lines (30 loc) · 1.29 KB
/
web_access.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
from selenium import webdriver
import assistant_speaks as ass
def find_web(text):
driver = webdriver.Firefox()
driver.implicitly_wait(1)
driver.maximize_window()
if 'youtube' in text.lower():
ass.assistant_speaks("Opening in youtube")
indx = text.lower().split().index('youtube')
query = text.split()[indx + 1:]
driver.get("http://www.youtube.com/results?search_query =" + '+'.join(query))
return
elif 'wikipedia' in text.lower():
ass.assistant_speaks("Opening Wikipedia")
indx = text.lower().split().index('wikipedia')
query = text.split()[indx + 1:]
driver.get("https://en.wikipedia.org/wiki/" + '_'.join(query))
return
else:
if 'google' in text:
indx = text.lower().split().index('google')
query = text.split()[indx + 1:]
driver.get("https://www.google.com/search?q =" + '+'.join(query))
elif 'search' in text:
indx = text.lower().split().index('google')
query = text.split()[indx + 1:]
driver.get("https://www.google.com/search?q =" + '+'.join(query))
else:
driver.get("https://www.google.com/search?q =" + '+'.join(text.split()))
return