[Python] How can I Open a Webpage Already Logged In?

Discussão em 'Python' iniciado por Stack, Julho 30, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to open a webpage using my existing Chrome profile/user data in order to avoid having to login. Ideally I'd like to do this in a new window that I can later close and not affect any other open Chrome pages.
    Whatever I try opens a new window that is not logged into Chrome nor the website.

    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service

    path = Service(r"C:/...chromedriver.exe") #path to chromedriver

    options = webdriver.ChromeOptions()
    options.add_argument(r"--user-date-dir=C:/Users/*username*/AppData/Local/Google/Chrome/User Data")
    options.add_argument(r"--profile-directory=*profilename*")
    options.add_argument('--no-sandbox')
    options.add_argument('--disable-gpu')
    options.add_experimental_option('excludeSwitches', ['enable-logging'])

    browser = webdriver.Chrome(service=path, options=options)
    url = "https://..."
    browser.get(url)

    Continue reading...

Compartilhe esta Página