selenium README

项目的 README,来自 github.com/oss-invisible/selenium。合并为一个 markdown 文件:README.md。

invisible_selenium, Selenium's API on an anti-detect Firefox. An animation: the import that changes, the fingerprint set inside the engine, a mouse that moves like a hand, and the options for a reproducible run.

Selenium gets caught by anti-bots and captchas.
This one runs on an anti-detect Firefox with an undetected fingerprint, compatible with your existing Selenium code.

Decodo residential proxies, free trial (sponsored)
Sponsored

How it works

Anti-bots ask two questions, and reCAPTCHA, hCaptcha and Cloudflare Turnstile score the answers. invisible_selenium answers yes to both.

1. Is this a real browser? Yes. It is Firefox, patched at the C++ source level.

2. Is a real person using it? Yes. The actions are humanized in the driver.


Install

Windows, in PowerShell:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
$env:Path = "$env:USERPROFILE\.local\bin;$env:Path"
uv init --python ">=3.11" my-project
cd my-project
uv add invisible-selenium
uv run invisible-selenium fetch

Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env
uv init --python ">=3.11" my-project
cd my-project
uv add invisible-selenium
uv run invisible-selenium fetch

Supported platforms: Windows x86_64 / ARM64 (the x86_64 engine, under Windows' own emulation), Linux x86_64. Linux arm64 is no longer supported from firefox-56 (firefox-55 is the last engine built for it).

Then save one of the examples below as main.py in my-project and run it with uv run main.py.


Usage

Selenium's API, with no code changes. The same webdriver, By, WebDriverWait and expected_conditions. If you already use Selenium, switching is the import:

- from selenium import webdriver
- from selenium.webdriver.common.by import By
+ from invisible_selenium import webdriver
+ from invisible_selenium.webdriver.common.by import By
from invisible_selenium import webdriver
from invisible_selenium.webdriver.common.by import By
from invisible_selenium.webdriver.support.ui import WebDriverWait
from invisible_selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Firefox()
driver.get("https://example.com")
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.TAG_NAME, "a"))).click()  # the mouse arcs to the link
print("seed =", driver.seed)   # log it to replay the run
driver.quit()

Every session gets a distinct fingerprint (GPU, audio, fonts, screen, ~200 fields). Do not install Selenium alongside it: this package already implements its API.

Options

driver = webdriver.Firefox(
    seed=42,                        # same seed, same fingerprint, every run
    proxy={"server": "socks5://host:1080", "username": "u", "password": "p"},
    timezone="America/New_York",    # default: derived from the proxy's exit IP
    pin={"screen.width": 2560, "screen.height": 1440},   # force fields, the rest stays seed-derived
    headless=True,                  # hidden desktop, real rendering: same fingerprint as headed
    profile_dir="./profile",        # cookies and storage survive the run
)

Proxies can be socks5, socks4, http or https, and DNS goes through them too. FirefoxOptions work as they do in Selenium, -headless included. The fields you can pin are the same as in invisible_playwright: pinning.

CLI

invisible-selenium fetch      # download the engine if missing, check every cached one, print the path
invisible-selenium version    # wrapper, core and engine versions

Switching from another tool?

Development

The setup and the test commands are in CONTRIBUTING.md.

License

MIT, see LICENSE. The Juggler client it drives the browser with lives in invisible-core, which carries two files taken from Playwright's driver under Apache-2.0. The patched Firefox binary is MPL-2.0, built from oss-invisible/firefox_antidetect_patch.

Disclaimer

This project is for educational purposes only. It is provided as-is, with no warranties. I take no responsibility for how it is used. Use it at your own risk and in compliance with the laws of your jurisdiction.


Built by Federico Elia  LinkedIn

tests License: MIT Python 3.11+

selenium (oss-invisible/selenium)

正在搜索数据库…

这是什么?一个 Selenium 的无缝替代品,运行在经 C++ 打补丁的防检测 Firefox 上,拥有无法被识别的浏览器指纹和拟人化的鼠标/输入动作,因此反机器人系统和验证码(reCAPTCHA、hCaptcha、Cloudflare Turnstile)不会把它标记为自动化。
这是一个全新的自动化工具,还是能配合我现有的 Selenium 代码?它是一个 Python 库,完全复刻 Selenium 的 API(webdriver、By、WebDriverWait、expected_conditions),因此现有 Selenium 脚本只需改一下导入就能用。
怎么把现有的 Selenium 脚本切换过来?把 Selenium 的导入换成 invisible_selenium 即可;FirefoxOptions、-headless 以及其余 API 都保持不变。不要让 Selenium 和它同时安装,因为本包已经实现了 Selenium 的 API。
运行它需要什么?Python 3.11 或更高版本,平台为 Windows(x86-64 或 ARM64,ARM64 通过 Windows 自带的 x86-64 引擎模拟)或 Linux(x86-64 或 arm64)。
在生产环境中依赖它安全吗?作者明确将其定位为仅供教育用途,按“原样”提供且不作任何担保,也不对其使用方式承担任何责任——因此请把它当作实验性工具,而不是有保障的生产工具。
它究竟是怎么骗过机器人检测的?浏览器指纹(navigator、GPU/WebGL、canvas、字体、音频、WebRTC、时区)是在打补丁后的 Firefox 引擎内部设置的,而不是通过 JavaScript 注入,而且没有 geckodriver/Marionette,因此 navigator.webdriver 永远不会开启。在此基础上,点击和拖拽会沿着拟人化的鼠标轨迹、配合真实的时间节奏进行。
它和 selenium-stealth 有什么不同?selenium-stealth 从 JavaScript 层面给页面打补丁,且自 2021 年 12 月起就再未更新;而 invisible_selenium 是在 C++ 源码层面给 Firefox 本身打补丁。
它支持代理吗?支持——socks5、socks4、http 和 https 代理都受支持,DNS 解析也会经由代理进行。
有针对其他自动化框架的版本吗?有,同一引擎还支撑着 invisibleplaywright(Playwright API)、invisiblepuppeteer(Python 版 Puppeteer API)和 invisibleplaywrightmcp(通过 MCP 暴露给 AI 智能体)。
大小
13.1 MB
星标
271
时长
2年
提交 · 90 天