Python Forum
Can't access the net using Python's Selenium module
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't access the net using Python's Selenium module
#1
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
Reply
#2
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to access variables from dirsync module steve_shambles 3 3,872 Apr-02-2020, 08:18 AM
Last Post: steve_shambles
  Python for MS Access DB Kundan 0 1,872 Feb-20-2020, 08:27 AM
Last Post: Kundan
  Access list items in Python kamaleon 2 2,345 Dec-31-2019, 11:10 AM
Last Post: kamaleon
  Access webcam via python ArnabRoyBatman 1 4,292 Jun-15-2017, 05:19 AM
Last Post: j.crater
  Access online database from python d4py 5 9,388 Dec-23-2016, 11:28 PM
Last Post: d4py

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020