Python chrome opens with “Data;” with selenium

Viewed 1932

I am using python selenium for web scraping, but after running the below codes, chrome is launched but did not get the website as I want, instead, it shows 'data;' in url bar.

Could anyone help with the problem? Many thanks!!

PS: My chrome is 88.and chromedriver is also 88. the path of chrome and chromedriver are different, one is in desktop and the other is C://

    import selenium
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    import time
    import random
    option = Options()
    option.add_experimental_option('excludeSwitches', ['enable-logging'])
    option.add_argument('--remote-debugging-port=9222')
    driver =webdriver.Chrome(executable_path='C:/Users/Desktop/chromedriver.exe')
    driver.get("https://www.youtube.com")  
2 Answers

Instead of using this

from selenium.webdriver.chrome.options import Options
options = options()

use this

options = webdriver.ChromeOptions()

and I would suggest you to put everything in the same project directory. which is a best practice.


Once you've put the chromedriver in the same directory. do this:

from os import getcwd
driver = webdriver.Chrome(getcwd() + "\chromedriver.exe", options=options)

Also, try to close the old chrome windows.

It will go to data:// and after that it will redirect to your website. And also follow Jiya's answer as well.

Related