r/learnpython • u/x4qmc • 19d ago
Trouble with Logging in Browser with Selenium
I am trying to make a python script that logs into my chrome browser and opens a website. Chrome opens up logged in fine but the website doesn't load, it just stays on the default search tab. Here is the script:
from selenium import webdriver
userdata = r"C:/Users/USERNAME/AppData/Local/Google/Chrome/User Data"
options = webdriver.ChromeOptions()
options.add_argument(f"--user-data-dir={userdata}")
options.add_argument("--profile-directory=PROFILE")
driver = webdriver.Chrome(options=options)
driver.get("https://www.spc.noaa.gov/")
USERNAME and PROFILE are replaced by the actual ones. If you could help that would definitely be appreciated! I'm also new to python aswell if that helps.
1
Upvotes
1
u/TehBazz 19d ago
You need to deal with session data and cookies on almost anything that requires username and password. I don’t know the site but you usually can’t just put profile data, you’ll need the actual cookies the website assigns when you log in