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

发布于 2025-01-15 11:44:07 字数 252 浏览 3 评论 0原文

我正在尝试使用 selenium Python 访问网站。 但该网站正在通过cloudflare不断检查。 没有其他页面出现。

检查此处的屏幕截图。

输入图像描述这里

我尝试过未检测到的 Chrome,但它根本不起作用。

I am trying to access a site using selenium Python.
But the site is checking and checking continuously by cloudflare.
No other page is coming.

Check the screenshot here.

enter image description here

I have tried undetected chrome but it is not working at all.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

故事↓在人 2025-01-22 11:44:07

未检测到的 chrome 是指未检测到的 chromedriver 吗?:

无论如何,未检测到的 chromedriver 对我有用:

未检测到的 chromedriver

Github: 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')

我的 POV

在此处输入图像描述
输入图像描述这里


登录您的 Google 帐户的快速设置代码:

Github: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 ---------- ]

By undetected chrome do you mean undetected chromedriver?:

Anyways, undetected-chromedriver works for me:

Undetected chromedriver

Github: https://github.com/ultrafunkamsterdam/undetected-chromedriver

pip install undetected-chromedriver

Code that gets a cloudflare protected site:

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

My POV

enter image description here
enter image description here


Quick setup code that logs into your google account:

Github: 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 ---------- ]
别忘他 2025-01-22 11:44:07

https://github.com/seleniumbase/SeleniumBase 具有未检测到的 chromedriver 模式 (--uc / uc=True)。

pip install seleniumbase 后,类似这样的脚本将绕过带有 Cloudflare Turnstile 的站点。

from seleniumbase import SB

with SB(uc=True) as sb:
    sb.open("https://nowsecure.nl/#relax")
    sb.sleep(2)
    if not sb.is_text_visible("OH YEAH, you passed!", "h1"):
        sb.get_new_driver(uc=True)
        sb.open("https://nowsecure.nl/#relax")
        sb.sleep(2)
    sb.assert_text("OH YEAH, you passed!", "h1", timeout=4)
    sb.sleep(2)

(使用 sb.driver 访问原始驱动程序。)

还有一种简单的 driver 格式:

from seleniumbase import Driver
import time

driver = Driver(uc=True)
driver.get("https://nowsecure.nl/#relax")
time.sleep(4)
driver.quit()

它可以绕过大多数站点的检测:

https://github.com/seleniumbase/SeleniumBase has undetected-chromedriver mode (--uc / uc=True).

After pip install seleniumbase, a script like this will bypass a site with Cloudflare turnstiles.

from seleniumbase import SB

with SB(uc=True) as sb:
    sb.open("https://nowsecure.nl/#relax")
    sb.sleep(2)
    if not sb.is_text_visible("OH YEAH, you passed!", "h1"):
        sb.get_new_driver(uc=True)
        sb.open("https://nowsecure.nl/#relax")
        sb.sleep(2)
    sb.assert_text("OH YEAH, you passed!", "h1", timeout=4)
    sb.sleep(2)

(Use sb.driver to access the raw driver.)

There's also a simple driver format:

from seleniumbase import Driver
import time

driver = Driver(uc=True)
driver.get("https://nowsecure.nl/#relax")
time.sleep(4)
driver.quit()

It can bypass detection on most sites:

做个少女永远怀春 2025-01-22 11:44:07

简单的方法很有用:

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)

The simple method is useful:

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文