这是最近的问题,我想是三四天前开始的。它并没有与我自己的系统隔离,因为我也在远程服务器(Windows 10、Windows Server)上运行该软件。它也不是孤立于任何特定 URL,因为我现在无法通过任何具有此检查的 URL。
Title: "Just a moment..." "Checking your browser before accessing URL". "This process is automatic. Your browser will redirect to your requested content shortly." "Please allow up to 5 seconds..." "DDos Protection by Cloudflare" "Ray Id: xxxxxxxxxxxxxxxxxx"
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('wwww.etherdelta.com')
有谁知道我如何解决这个问题;或者是时候放下可怜的提米(程序)了吗?
最佳答案
我在 Firefox 上遇到了同样的问题。我能够通过切换到 Chrome 来解决它。
示例代码:
from selenium import webdriver
url = "<WEBSITE>"
options = webdriver.ChromeOptions()
options.add_argument("--disable-blink-features=AutomationControlled")
driver = webdriver.Chrome(options=options)
driver.get(url)
“--disable-blink-features=AutomationControlled”隐藏“navigator.webdriver”标志。见 Selenium webdriver: Modifying navigator.webdriver flag to prevent selenium detection
编辑
您还必须更改 chromedriver 的一些默认变量。
perl 示例:
perl -pi -e 's/cdc_/dog_/g' /path/to/chromedriver
有关更多详细信息,请查看原始帖子。见 Can a website detect when you are using selenium with chromedriver?
编辑 2
Cloudflare 不断调整他们的算法,因此您可以尝试使用 undetected-chromedriver 而不是手动更改 chromedriver。
undetected-chromedriver 是一个优化的 Selenium Chromedriver 补丁,它不会触发反机器人服务。它会自动下载驱动程序二进制文件并修补它。
这是否可行取决于网站和当前的开发状态。 Cloudflare 似乎在跟踪 undetected-chromedriver 的发展。
import undetected_chromedriver as uc
url = "<WEBSITE>"
driver= uc.Chrome()
driver.get(url)
关于python - Selenium 卡在 "Checking your browser before accessing URL",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64165726/