1

I am trying to click on one link from a list of links, wait one second (not added yet) and then click on the next link. Using selenium and bs4. This is my code:

links = ['https://www.bing.com', 'https://www.google.com', 'https://www.yahoo.com'] for url in links: url = "'"+url+"'" print(url,'\n') browser = webdriver.Firefox browser.get(url) 

and this is the error I am getting:

Traceback (most recent call last): File "C:/Users/SK/PycharmProjects/untitled/linkedin_bot.py", line 38, in <module> browser.get(url) TypeError: get() missing 1 required positional argument: 'url' 

What exactly am I doing wrong and how to solve it? Thanks

1

2 Answers 2

1

You need to change browser = webdriver.Firefox to browser = webdriver.Firefox(). As it is, when you call browser.get(url), it is expecting a webdriver.Firefox instance as the first argument and a url as the second argument. When you include the parentheses, you are creating an instance of webdriver.Firefox and Python automatically gives it as the first argument.

    0

    The main problem is that the "url" variable name is the same as the "url" in the for loop. Try renaming the variable.

    Here is the amended code. I have used Chrome as the driver, but you can use Firefox or any other driver. Remember to change the executable path of the driver to match your situation.

    from selenium import webdriver import time browser = webdriver.Chrome(executable_path='C:\Chrome\chromedriver.exe') links = ['https://www.bing.com', 'https://www.google.com', 'https://www.yahoo.com'] for url in links: urls = "'"+url+"'" print(urls,'\n') browser.get(url) time.sleep(1) 

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.