Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用selenium避免被浏览器检测到_Python_Selenium_Selenium Firefoxdriver - Fatal编程技术网

Python 如何使用selenium避免被浏览器检测到

Python 如何使用selenium避免被浏览器检测到,python,selenium,selenium-firefoxdriver,Python,Selenium,Selenium Firefoxdriver,我正在处理一个使用Incapsula防火墙保护的网站,我认为它被检测为机器人行为 这是我的密码: 当前输出:为空白白色页面 作为正常浏览器行为的预期输出: 这建议了几种方法。同时检查讨论。这建议了几种方法。同时检查讨论 from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from sel

我正在处理一个使用
Incapsula
防火墙保护的网站,我认为它被检测为机器人行为

这是我的密码:

当前输出:为空白白色页面

作为正常浏览器行为的预期输出

这建议了几种方法。同时检查讨论。这建议了几种方法。同时检查讨论
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep


def main(url):
    driver = webdriver.Firefox()
    driver.get(url)
    WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.CSS_SELECTOR, "#location"))).send_keys("06037")
    WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.CSS_SELECTOR, ".action-btn"))).click()
    WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.CSS_SELECTOR, "li.gs-option:nth-child(2) > a:nth-child(1) > div:nth-child(2)"))).click()
    WebDriverWait(driver, 10).until(
        EC.presence_of_all_elements_located((By.CSS_SELECTOR, "button[class^=sc]")))[2].click()
    driver.execute_script("window.scrollBy(0,400)")
    sleep(0.01)
    WebDriverWait(driver, 10).until(
        EC.presence_of_all_elements_located((By.CSS_SELECTOR, "img.img")))[1].click()
    WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.CSS_SELECTOR, "button[data-test-id='PrimaryCare']"))).click()
    WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.CSS_SELECTOR, "button[data-test-id$='AllPrimaryCareProviders']"))).click()


main("https://connect.werally.com/county-plan-selection/uhc.mnr/zip")