网站使用ChromeDriver和Chrome浏览器通过Selenium导航到禁止访问的页面,可能是受Bot保护的 [英] Website navigates to no-access page using ChromeDriver and Chrome through Selenium probably Bot Protected

查看:559
本文介绍了网站使用ChromeDriver和Chrome浏览器通过Selenium导航到禁止访问的页面,可能是受Bot保护的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标站点是 https://www.nike.com/kr/ko_kr 使用selenium driver.get通过webdriver.Chrome().get连接到此目标时,连接已完成.

My target site is https://www.nike.com/kr/ko_kr When using selenium driver.get to connect to this target using webdriver.Chrome().get, the connection is done.

但是,如果我单击元素以使用我的手或 element_find_xpath(),它会重定向无访问权限的页面(可能是漫游器保护程序),并且我什么也做不了(其他目标的子页面等).

But if I click elements to use my hand or element_find_xpath(), it redirected no-access page(probably bot protector) and I cant do anything(other target's sub page etc...).

我更改了IP用户代理,但它也重定向了无访问权限. 如何欺骗网站并启用普通访问权限?

I changed user-agent, ip but it redirected no-access too. How can I cheat the site and enable normal access?

我也更改了用户代理等.但是没有用

I have also changed the user-agent and etc.. But didn't work

代码试用的快照:

推荐答案

您可以尝试在两次操作之间设置几秒钟的超时时间,以使操作更具人性化".

You can try to set a timeout of a few seconds between your actions, to act more "human-like".

有一种隐式和显式的方式(来源: Selenium Waits ).

There is an implicit and an explicit way (source: Selenium Waits).

显式等待是您定义的代码,用于在继续执行代码之前先等待特定条件发生.极端的情况是time.sleep(),它将条件设置为要等待的确切时间段

An explicit wait is a code you define to wait for a certain condition to occur before proceeding further in the code. The extreme case of this is time.sleep(), which sets the condition to an exact time period to wait

您可能正在寻找隐式的方式:隐式等待告诉WebDriver在尝试查找不立即可用的一个或多个元素时,轮询DOM一定时间.默认设置为0.设置后,将在WebDriver对象的生存期内设置隐式等待.

You are probably looking for the implicit way: An implicit wait tells WebDriver to poll the DOM for a certain amount of time when trying to find any element (or elements) not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object.

from selenium import webdriver

driver = webdriver.Firefox()
driver.implicitly_wait(10) # seconds
driver.get("http://somedomain/url_that_delays_loading")
myDynamicElement = driver.find_element_by_id("myDynamicElement")

另一种等待几秒钟的方法适用于打包时间:

Another way to wait for a few seconds works with the package time:

import time 
time.sleep(5) #wait 5 seconds

这篇关于网站使用ChromeDriver和Chrome浏览器通过Selenium导航到禁止访问的页面,可能是受Bot保护的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆