相关疑难解决方法(0)

当您使用含硒的硒时,网站是否可以检测到?

我一直在用Chromedriver测试Selenium,我注意到有些页面可以检测到你正在使用Selenium,即使根本没有自动化.即使我只是通过Selenium和Xephyr使用chrome手动浏览我经常会得到一个页面,说明检测到可疑活动.我检查了我的用户代理和浏览器指纹,它们与普通的Chrome浏览器完全相同.

当我在普通镀铬中浏览这些网站时,一切正常,但是当我使用Selenium的时候,我已经检测到了.

从理论上讲,chromedriver和chrome应该看起来与任何网络服务器完全相同,但不知怎的,他们可以检测到它.

如果你想要一些测试代码试试这个:

from pyvirtualdisplay import Display
from selenium import webdriver

display = Display(visible=1, size=(1600, 902))
display.start()
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--disable-extensions')
chrome_options.add_argument('--profile-directory=Default')
chrome_options.add_argument("--incognito")
chrome_options.add_argument("--disable-plugins-discovery");
chrome_options.add_argument("--start-maximized")
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.delete_all_cookies()
driver.set_window_size(800,800)
driver.set_window_position(0,0)
print 'arguments done'
driver.get('http://stubhub.com')
Run Code Online (Sandbox Code Playgroud)

如果您浏览stubhub,您将在一两个请求中被重定向和"阻止".我一直在研究这个,我无法弄清楚他们如何判断用户是否正在使用Selenium.

他们是如何做到的呢?

编辑更新:

我在Firefox中安装了Selenium IDE插件,当我在普通的firefox浏览器中使用附加插件访问stubhub.com时,我被禁止了.

编辑:

当我使用Fiddler来查看来回发送的HTTP请求时,我注意到"假浏览器"的请求通常在响应头中有"无缓存".

编辑:

这样的结果是否有办法检测到我在Javascript的Selenium Webdriver页面中建议无法检测何时使用webdriver.但是这个证据表明不然.

编辑:

该网站将指纹上传到他们的服务器,但我检查了使用chrome时硒的​​指纹与指纹相同.

编辑:

这是他们发送到服务器的指纹有效负载之一

{"appName":"Netscape","platform":"Linuxx86_64","cookies":1,"syslang":"en-US","userlang":"en-US","cpu":"","productSub":"20030107","setTimeout":1,"setInterval":1,"plugins":{"0":"ChromePDFViewer","1":"ShockwaveFlash","2":"WidevineContentDecryptionModule","3":"NativeClient","4":"ChromePDFViewer"},"mimeTypes":{"0":"application/pdf","1":"ShockwaveFlashapplication/x-shockwave-flash","2":"FutureSplashPlayerapplication/futuresplash","3":"WidevineContentDecryptionModuleapplication/x-ppapi-widevine-cdm","4":"NativeClientExecutableapplication/x-nacl","5":"PortableNativeClientExecutableapplication/x-pnacl","6":"PortableDocumentFormatapplication/x-google-chrome-pdf"},"screen":{"width":1600,"height":900,"colorDepth":24},"fonts":{"0":"monospace","1":"DejaVuSerif","2":"Georgia","3":"DejaVuSans","4":"TrebuchetMS","5":"Verdana","6":"AndaleMono","7":"DejaVuSansMono","8":"LiberationMono","9":"NimbusMonoL","10":"CourierNew","11":"Courier"}}
Run Code Online (Sandbox Code Playgroud)

它的硒和铬相同

编辑:

VPN仅供一次使用,但在加载第一页后会被检测到.很明显,正在运行一些javascript来检测Selenium.

javascript python selenium google-chrome selenium-chromedriver

303
推荐指数
21
解决办法
13万
查看次数

是否有无法检测到的 Selenium WebDriver 版本?

我在住宅代理网络后面的Ubuntu服务器上通过 Selenium 运行 Chrome 驱动程序。然而,我的硒正在被检测到。有没有办法让 Chrome 驱动程序和 Selenium 100% 无法检测?

我已经尝试了很长时间,但我忘记了我所做的许多事情,包括:

  1. 尝试不同版本的 Chrome
  2. 添加几个标志并从 Chrome 驱动程序文件中删除一些词。
  3. 使用隐身模式在代理(住宅代理)后面运行它。
  4. 加载配置文件。
  5. 随机鼠标移动。
  6. 随机化一切。

我正在寻找 100% 无法检测到的真正 Selenium 版本。如果那曾经存在过。或者机器人跟踪器无法检测到的另一种自动化方式。

这是浏览器启动的一部分:

sx = random.randint(1000, 1500)
sn = random.randint(3000, 4500)

display = Display(visible=0, size=(sx,sn))
display.start()


randagent = random.randint(0,len(useragents_desktop)-1)

uag = useragents_desktop[randagent]
#this is to prevent ip leaking
preferences =
    "webrtc.ip_handling_policy" : "disable_non_proxied_udp",
    "webrtc.multiple_routes_enabled": False,
    "webrtc.nonproxied_udp_enabled" : False

chrome_options.add_experimental_option("prefs", preferences)
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-impl-side-painting")
chrome_options.add_argument("--disable-setuid-sandbox")
chrome_options.add_argument("--disable-seccomp-filter-sandbox")
chrome_options.add_argument("--disable-breakpad")
chrome_options.add_argument("--disable-client-side-phishing-detection")
chrome_options.add_argument("--disable-cast")
chrome_options.add_argument("--disable-cast-streaming-hw-encoding")
chrome_options.add_argument("--disable-cloud-import")
chrome_options.add_argument("--disable-popup-blocking")
chrome_options.add_argument("--ignore-certificate-errors")
chrome_options.add_argument("--disable-session-crashed-bubble")
chrome_options.add_argument("--disable-ipv6")
chrome_options.add_argument("--allow-http-screen-capture") …
Run Code Online (Sandbox Code Playgroud)

selenium google-chrome webdriver selenium-chromedriver selenium-webdriver

20
推荐指数
2
解决办法
3万
查看次数

无法使用Selenium自动化Chase站点登录

当我尝试使用Selenium(Python)登录Chase网站时,我遇到以下错误消息:

追逐登录失败图像

但是,使用"人"登录工作正常.似乎当Selenium找到一个元素时会引发问题.

我错过了什么吗?我试图在stackoverflow上找到答案,但无济于事.

更新:

预期的结果是脚本将成功允许我以编程方式登录.

这是下面的代码示例:

import time
import os

from selenium import webdriver

CHASE_USER_ID = os.getenv('CHASE_USER_ID', None)
CHASE_PASSWORD = os.getenv('CHASE_PASSWORD', None)

assert CHASE_USER_ID is not None, 'Chase user id not set'
assert CHASE_PASSWORD is not None, ' Chase password not set'


def main():
    chrome_options = webdriver.ChromeOptions()
    driver = webdriver.Chrome(r'./chromedriver', chrome_options=chrome_options)

    try:
        driver.get('https://secure07c.chase.com/web/auth/#/logon/logon/chaseOnline?')

        time.sleep(2)

        user_element = driver.find_element_by_id('userId-input-field')  # Finding an element here seems to make the login process fail 
        user_element.send_keys(CHASE_USER_ID)

        password_element = driver.find_element_by_id('password-input-field')
        password_element.send_keys(CHASE_PASSWORD)

        time.sleep(2)

        password_element.submit()

        time.sleep(10)
    finally:
        driver.quit()


if …
Run Code Online (Sandbox Code Playgroud)

python selenium google-chrome webdriver selenium-chromedriver

13
推荐指数
1
解决办法
1836
查看次数

Selenium 停留在“在访问 URL 之前检查您的浏览器”

这是最近的问题,我想是三四天前开始的。它并没有与我自己的系统隔离,因为我也在远程服务器(Windows 10、Windows Server)上运行该软件。它也不是孤立于任何特定 URL,因为我现在无法通过任何具有此检查的 URL。

标题:“稍等……”“在访问 URL 之前检查您的浏览器”。“这个过程是自动的。你的浏览器很快就会重定向到你请求的内容。” “请允许最多 5 秒……”“Cloudflare 的 DDos 保护”“Ray Id:xxxxxxxxxxxxxxxxxx”

  • 我尝试过不同的系统(均基于 Windows)
  • 我尝试过不同的驱动程序(壁虎和铬)
  • 我尝试了不同的网址
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('wwww.etherdelta.com')
Run Code Online (Sandbox Code Playgroud)

有谁知道我如何解决这个问题;或者是时候放下可怜的提米(程序)了吗?

python selenium

13
推荐指数
2
解决办法
1万
查看次数

有没有办法从Javascript中检测到我在Selenium Webdriver页面中

我想在我的测试中抑制TinyMCE的初始化,并且如果Javascript可以检测到我在Selenium自动化页面中运行,则可以轻松完成.

那么,是否有一些我可以用来检测Selenium驱动程序的JS代码?或者,如何扩展userAgent字符串以包含我可以从JS检测到的模式?

如果它真的很重要,我在Mac OS X上运行黄瓜和水豚.

javascript selenium webdriver cucumber capybara

12
推荐指数
2
解决办法
1万
查看次数

网页正在使用 Chromedriver 作为机器人检测 Selenium Webdriver

我正在尝试使用 python抓取https://www.controller.com/,并且由于该页面检测到使用 bot 的机器人pandas.get_html,并且使用用户代理和旋转代理进行请求,因此我求助于使用 selenium webdriver。但是,这也被检测为带有以下消息的机器人。任何人都可以解释我怎样才能克服这个问题?:

请原谅我们的打扰... 当您浏览 www.controller.com 时,您的浏览器的某些方面让我们认为您是一个机器人。发生这种情况的原因有以下几个: 您是一名超级用户,以超人的速度浏览此网站。您已在 Web 浏览器中禁用 JavaScript。第三方浏览器插件(例如 Ghostery 或 NoScript)阻止 JavaScript 运行。此支持文章中提供了其他信息。要请求解锁,请填写下面的表格,我们会尽快审核”

这是我的代码:

from selenium import webdriver
import requests
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
options = webdriver.ChromeOptions()
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
#options.add_argument('headless')
driver = webdriver.Chrome(chrome_options=options)
driver.get('https://www.controller.com/')
driver.implicitly_wait(30)
Run Code Online (Sandbox Code Playgroud)

python selenium bots webdriver selenium-webdriver

11
推荐指数
1
解决办法
3万
查看次数

Selenium 应用程序在 Heroku 上托管时重定向到 Cloudflare 页面

我制作了一个不和谐的机器人,它使用 selenium 访问网站并获取信息,当我在本地运行代码时,我没有任何问题,但是当我部署到 Heroku 时,我得到的第一个 URL 将我重定向到 page Attention Required! | Cloudflare

我努力了:

还有许多其他具有我使用的相同设置的:

options = Options()
options.binary_location = os.environ.get("GOOGLE_CHROME_BIN")
options.add_experimental_option("excludeSwitches", ["enable-logging", "enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument("--disable-blink-features=AutomationControlled")
options.add_argument("--headless")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--no-sandbox")
self.driver = webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH"), options=options)
self.driver.execute_cdp_cmd('Network.setUserAgentOverride', {
    "userAgent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.53 Safari/537.36'})
Run Code Online (Sandbox Code Playgroud)

但这不起作用,代码仅在本地运行

PS:本地我在Windows上

我重定向到的页面来源: https://gist.github.com/rafalou38/9ae95bd66e86d2171fc8a45cebd9720c 页面来源

python selenium captcha heroku cloudflare

11
推荐指数
1
解决办法
2万
查看次数

在firefox webdriver选项中排除开关

使用Selenium和python,我可以使用Chrome webdriver来做到这一点:

options.add_experimental_option("excludeSwitches", ["enable-automation"])
driver = webdriver.Chrome(options = options)
Run Code Online (Sandbox Code Playgroud)

但是我找不到Firefox的webdriver选项的类似属性。是否存在?

python selenium selenium-firefoxdriver

8
推荐指数
2
解决办法
335
查看次数

通过 Selenium Python 在普通/无头模式下使用 ChromeDriver/Chrome 访问 Cloudflare 网站有什么区别

我有一个问题 --headlessPython Selenium for Chrome 模式。

代码

 from selenium import webdriver
 from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

 CHROME_DRIVER_DIR = "selenium/chromedriver"

 chrome_options = webdriver.ChromeOptions()
 caps = DesiredCapabilities().CHROME
 chrome_options.add_argument("--disable-dev-shm-usage")
 chrome_options.add_argument("--remote-debugging-port=9222")
 chrome_options.add_argument("--headless")  # Runs Chrome in headless mode.
 chrome_options.add_argument('--no-sandbox')  # # Bypass OS security model
 chrome_options.add_argument("--disable-extensions")
 chrome_options.add_argument("--disable-gpu")

 browser = webdriver.Chrome(desired_capabilities=caps, executable_path=CHROME_DRIVER_DIR, options=chrome_options)

 browser.get("https://www.manta.com/c/mm2956g/mashuda-contractors")
 print(browser.page_source)
 browser.quit()
Run Code Online (Sandbox Code Playgroud)

当我删除chrome_options.add_argument("--headless")所有工作正常时,但是--headless*有了下一个问题

Please enable cookies.

Error 1020 Ray ID: 53fd62b4087d8116 • 2019-12-04 11:19:28 UTC

Access denied

What happened?
This website is using a security service to …
Run Code Online (Sandbox Code Playgroud)

python selenium cloudflare selenium-chromedriver google-chrome-headless

8
推荐指数
3
解决办法
1万
查看次数

如何使用 python 避免机器人检测并抓取网站?

我的问题:

我想抓取以下网站: https: //www.coches.net/segunda-mano/。但每次我用 python selenium 打开它时,我都会收到消息,他们将我检测为机器人。我怎样才能绕过这个检测?首先我尝试使用 selenium 编写简单的代码:

from selenium import webdriver
from bs4 import BeautifulSoup

browser = webdriver.Chrome('C:/Python38/chromedriver.exe')
URL = 'https://www.coches.net/segunda-mano/'
browser.get(URL)
Run Code Online (Sandbox Code Playgroud)

然后我按照要求尝试了它,但我也不起作用。

from selenium import webdriver
from bs4 import BeautifulSoup

from fake_useragent import UserAgent

import requests

ua = UserAgent()

headers = {"UserAgent":ua.random}

URL = 'https://www.coches.net/segunda-mano/'
r = requests.get(URL, headers = headers)

print(r.statuscode)
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我收到消息 403 = 状态代码,表明禁止访问该 URL。

不知道如何在不被阻止的情况下访问该网页。我将非常感谢你的帮助。提前致谢。

python selenium bots web-scraping python-requests

8
推荐指数
2
解决办法
4万
查看次数