invisible_selenium README

The project's README from github.com/feder-cr/invisible_selenium. As one markdown file: 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.

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

pip install invisible-selenium
python -m invisible_selenium fetch      # one-time download of the patched Firefox, sha256-verified

Requires Python 3.11 or newer. Supported platforms: Windows x86_64 / ARM64 (the x86_64 engine, under Windows' own emulation), Linux x86_64 / arm64.


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

git clone https://github.com/feder-cr/invisible_selenium && cd invisible_selenium
uv venv && uv pip install -e ".[dev]"
uv run pytest -q                      # unit
uv run pytest -q -m e2e               # against the real browser

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 feder-cr/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+

invisible_selenium (feder-cr/invisible_selenium)

Searching Database…

这是什么?一个 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 智能体)。
Creator
feder-cr
Size
12.4 MB
Stars
808
Age
2y
Commits · 90 Days