嗨,当使用 python 和 selenium 时,我在使用 cloudflare 的 DDos 保护访问站点时遇到问题
Hi, I am having problems with getting through to a site using DDos protection by cloudflare, when using python and selenium
我打算在网站上设置一个自动化流程。但是当我尝试使用 selenium 访问该站点时无法通过消息 'Checking your browser before accessing sit.no'。消息来自cloudflare.
我一直在尝试我在这里找到的一些代码,但没有用
1.
from selenium import webdriver
url = 'https://www.sit.no/'
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options)
driver.get(url)
2.
from selenium import webdriver
url = 'https://www.sit.no/'
options = webdriver.ChromeOptions()
options.add_argument("--disable-blink-features=AutomationControlled")
driver = webdriver.Chrome(options=options)
driver.get(url)
3.
import undetected_chromedriver as uc
url = 'https://www.sit.no/'
driver= uc.Chrome()
driver.get(url)
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import subprocess
#other imports
subprocess.Popen(
'"C:\Program Files\yourpathtochrome\chrome.exe" --remote-debugging-port=9222', shell=True)
options = webdriver.ChromeOptions()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = webdriver.Chrome(options=options)
driver.maximize_window()
driver.get('https://www.sit.no/')
input()
首先手动打开网站,完成浏览器检查。现在关闭所有 chrome 浏览器并将路径替换为您的 chrome.exe 路径。这会起作用,
我打算在网站上设置一个自动化流程。但是当我尝试使用 selenium 访问该站点时无法通过消息 'Checking your browser before accessing sit.no'。消息来自cloudflare.
我一直在尝试我在这里找到的一些代码,但没有用
1.
from selenium import webdriver
url = 'https://www.sit.no/'
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options)
driver.get(url)
2.
from selenium import webdriver
url = 'https://www.sit.no/'
options = webdriver.ChromeOptions()
options.add_argument("--disable-blink-features=AutomationControlled")
driver = webdriver.Chrome(options=options)
driver.get(url)
3.
import undetected_chromedriver as uc
url = 'https://www.sit.no/'
driver= uc.Chrome()
driver.get(url)
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import subprocess
#other imports
subprocess.Popen(
'"C:\Program Files\yourpathtochrome\chrome.exe" --remote-debugging-port=9222', shell=True)
options = webdriver.ChromeOptions()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = webdriver.Chrome(options=options)
driver.maximize_window()
driver.get('https://www.sit.no/')
input()
首先手动打开网站,完成浏览器检查。现在关闭所有 chrome 浏览器并将路径替换为您的 chrome.exe 路径。这会起作用,