Python Forum

Full Version: Can't access the net using Python's Selenium module
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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
this is just a function definition. you never call it. do you get any traceback? describe exactly what the problem is.
Also never use input as variable name - you override the input() function
(Jul-20-2020, 04:40 PM)buran Wrote: [ -> ]this is just a function definition. you never call it. do you get any traceback? describe exactly what the problem is.
Also never use input as variable name - you override the input() function

I haven't posted the whole script here. I have actually called the function in the later part. I'll surely change the variable. Thanks!