如何绕过cloudflare浏览器检查selenium Python

rlcwz9us  于 2023-01-13  发布在  Python
关注(0)|答案(2)|浏览(484)

我试图使用 selenium Python访问一个网站。但该网站正在检查和检查不断由cloudflare。没有其他页面来了。
点击这里查看截图。

我试过未检测到的 chrome ,但它是不工作的。

waxmsbnn

waxmsbnn1#

未检测到的chrome是指未检测到的chromedriver吗?:
无论如何,undetected-chromedriver为我工作:

未检测到chromedriver

给定值:https://github.com/ultrafunkamsterdam/undetected-chromedriver

pip install undetected-chromedriver

获取cloudflare保护站点的代码:

import undetected_chromedriver as uc
driver = uc.Chrome(use_subprocess=True)
driver.get('https://nowsecure.nl')

我的视点

第一节第一节第一节第一节第一次

登录谷歌账户的快速设置代码:

给定值:https://github.com/xtekky/google-login-bypass

import undetected_chromedriver as uc
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

#  ---------- EDIT ----------
email = 'email\n' # replace email
password = 'password\n' # replace password
#  ---------- EDIT ----------

driver = uc.Chrome(use_subprocess=True)
wait = WebDriverWait(driver, 20)
url = 'https://accounts.google.com/ServiceLogin?service=accountsettings&continue=https://myaccount.google.com%3Futm_source%3Daccount-marketing-page%26utm_medium%3Dgo-to-account-button'
driver.get(url)

wait.until(EC.visibility_of_element_located((By.NAME, 'identifier'))).send_keys(email)
wait.until(EC.visibility_of_element_located((By.NAME, 'password'))).send_keys(password)
print("You're in!! enjoy")

# [ ---------- paste your code here ---------- ]
mzsu5hc0

mzsu5hc02#

简单的方法是有用的:

from selenium import webdriver
import time 

browser = webdriver.Chrome()
browser.get(url)

# sleep to wait pass
time.sleep(3) 

html_source = browser.page_source
print(html_soup)

相关问题