Der Versuch, Chrome_undetected Selenium Treiber und tragbares Chrom zu verwenden

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Der Versuch, Chrome_undetected Selenium Treiber und tragbares Chrom zu verwenden

by Guest » 28 Jan 2025, 06:37

Ich habe den Code unten und ich habe Chrome tragbar unter
c:\Temp\googlEchromeportable64\app\chrome-Bin\chrome.exe
Wie kann ich unentdeckte_Cromedriver sagen? < / p>

Code: Select all

# Import the required libraries
import undetected_chromedriver as uc
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from webdriver_manager.chrome import ChromeDriverManager
import time

# Define Chrome options
options = uc.ChromeOptions()

# Set headless to False to run in non-headless mode
options.headless = False

# Chrome driver
driver = uc.Chrome(use_subprocess=True, options=options)

# Go to the desired URL
driver.get("https://library.usask.ca/#gsc.tab=0")

# Wait until the input field is visible
wait = WebDriverWait(driver, 10)
q_field = wait.until(EC.presence_of_element_located((By.ID, "primoQueryTemp")))

# Use JavaScript to focus the element
driver.execute_script("arguments[0].focus();", q_field)

# Initiate typing into the field
q_field.send_keys("_")

# Click the field to trigger any other events
q_field.click()

# Keep the browser open for observation
time.sleep(566)

# Close the driver
driver.quit()

Top