Skip to content
Advertisement

How to open multiple sites in Selenium with user input?

I’m fairly new to coding with Python and I had some questions regarding Selenium:

So basically what I’m trying is:

-user inputs multiple links to different sites

-the script opens the first link and closes the browser afterwards and opens the next link

-the user only inputs for example ‘google.com’ but the browser automatically opens ‘http://google.com’ (thats the reason why I try to append the link and the ‘http’ variable)

but I always have the following error code: line 18, in <module> driver.get(url) and Chrome opens a new tab with ‘data:,’ as the URL

JavaScript

Advertisement

Answer

Your logic/syntax is wrong. You have to fix the way you are attaching the ‘http://’ part. Following code is working for me:

from selenium import webdriver from time import sleep

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement