Selenium Driver.get (URL) öffnet die URL nichtPython

Python-Programme
Anonymous
 Selenium Driver.get (URL) öffnet die URL nicht

Post by Anonymous »

einfrom selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import time

# Setup Chrome options
chrome_options = Options()
chrome_options.add_argument("--headless=new") # Run in headless mode

# Set path to chromedriver
driver_path = "./chrome/chromedriver.exe"

# Start the WebDriver
service = Service(driver_path)
driver = webdriver.Chrome(service=service, options=chrome_options)

# Navigate to the page
driver.get("https://example.com")

# Optional: Wait for JavaScript to load
time.sleep(3)

# Find elements
title = driver.find_element(By.TAG_NAME, "h1").text
print(f"Page title: {title}")

# Close the browser
driver.quit()
< /code>
Es gibt mir keinen Fehler. Der Browser taucht auf, aber sonst passiert nichts. Ich habe versucht, ein neues Projekt zu erstellen und denselben Code auszuführen. Was ist das Problem und wie soll ich es beheben? Danke.
Ich habe den Code mit Python 3 in Windows 10 getestet.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post