我试着使用selenuim模块来获取一些网站unsuccessfull.这是我尝试:未检测到的_chromedriver添加用户配置文件使用代理。当我打开它与webdriver的Cloudflare不允许我处理。当我打开它与正常chrom它的作品罚款。任何idias?
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from datetime import datetime
import time
from undetected_chromedriver import Chrome
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print('Hey Elior, im on = ', current_time)
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\Owner\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 12")
driver = Chrome(chrome_options=options)
driver.get("https://www.example.com")
def login():
driver.get("site")
# identify username, password and signin elements
time.sleep(1)
driver.find_element(By.NAME, "username").click()
driver.find_element(By.NAME, "username").send_keys('')
time.sleep(1)
driver.find_element(By.NAME, "password").click()
driver.find_element(By.NAME, "password").send_keys('')
time.sleep(1)
# press on login button
driver.find_element(By.ID, "login-submit").click()
driver.maximize_window()
driver.execute_script("console.clear()") # clean the console
time.sleep(3)
1条答案
按热度按时间carvr3hs1#
您可以尝试使用Selenium-Profiles。
注意,headless几乎从来不会在不被发现的情况下工作。