Jul-20-2020, 04:37 PM
Hey there!
I am creating a program that concerns with accessing the net. But my script isn't able to do it. I have used selenium module. Please look into the code I have attached and let me know if it has any problem. I am connected to the internet and the rest of my script works perfectly as it should.
I am creating a program that concerns with accessing the net. But my script isn't able to do it. I have used selenium module. Please look into the code I have attached and let me know if it has any problem. I am connected to the internet and the rest of my script works perfectly as it should.
def search_web(input):
driver = webdriver.Chrome()
driver.implicitly_wait(1)
driver.maximize_window()
if 'youtube' in input.lower():
assistant_speaks("Opening in youtube")
indx = input.lower().split().index('youtube')
query = input.split()[indx + 1:]
driver.get("http://www.youtube.com/results?search_query =" + '+'.join(query))
return
elif 'wikipedia' in input.lower():
assistant_speaks("Opening Wikipedia")
indx = input.lower().split().index('wikipedia')
query = input.split()[indx + 1:]
driver.get("https://en.wikipedia.org/wiki/" + '_'.join(query))
return
else:
if 'google' in input:
indx = input.lower().split().index('google')
query = input.split()[indx + 1:]
driver.get("https://www.google.com/search?q =" + '+'.join(query))
elif 'search' in input:
indx = input.lower().split().index('google')
query = input.split()[indx + 1:]
driver.get("https://www.google.com/search?q =" + '+'.join(query))
else:
driver.get("https://www.google.com/search?q =" + '+'.join(input.split()))
return
