MCPcopy Index your code
hub / github.com/decodecaptcha/Browser-Env

github.com/decodecaptcha/Browser-Env @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
345 symbols 837 edges 39 files 96 documented · 28%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Browser-Env

Web crawlers use the real browser environment.

本项目不重复造轮子, 而是对已有的开源项目进行封装和集成, 使其适用于复杂多样的 Spider 项目需求.

依赖要求: windows 系统

Python 3.6+

selenium 3.4.0+

Chrome 浏览器应用版本 92+

本人实测: windows 10 专业版

Python 3.6.9

selenium-wire==4.6.0

undetected-chromedriver==3.0.6

selenium==3.141.0

Chrome 浏览器应用版本 92.0.4515.159

jsenv 推荐

  • 2023-04-01 更新: 更优雅的方式 异步/同步调用 nodejs 环境, 补环境

需要依赖:

安装 nodejs 环境

同时自定义 DOM 环境,需安装 jsdom 或者 canvas

npm install jsdom

npm install canvas

chrome_remote_pro 推荐

  • 2023-02-15 更新: 客户端 添加新功能 click, send, get_html 分别实现鼠标点击, 输入框输入, 获取页面元素等基础操作, 并使用 CSS 语法来定位
  • 2022-09-19 更新: 客户端不再使用 selenium 库, 基于chrome cdp协议 重写了一个客户端连接, 更少的依赖, 更高效

chrome_remote

远程 chrome 浏览器环境, 执行js脚本

原理:

chrome 可执行文件 使用启动选项 remote-debugging-port 打开 chrome 浏览器调试端口,

相当于打开一个调试服务, 客户端填写 debuggerAddress 连接, 这些 selenium 已经都有集成的了

由于是浏览器是命令行方式启动, 这和平常手动启动浏览器基本没有差别, 自然就绕过各种 webdriver 属性, 自动化工具检测

辛苦扣出来的js, 再也不用花几小时补环境, 该怎么抛弃execjs, nodejs ?

browserenv

基础的浏览器环境, 用于高度模拟 真实浏览器环境 执行js脚本

或对付 SecurityWorker, jsmvp 类型加固

wirebrowserenv

在 browserenv 基础上, wirebrowserenv 功能更加强大, 支持拦截网络请求 的浏览器环境

作用: 捕获的 HTTP 和 HTTPS 请求 拦截请求和响应 即时修改标题、参数、正文内容

wirebrowserenv_uc

对 undetected-chromedriver 的集成, 优化的 Selenium Chromedriver 补丁,

不会触发 Distill Network / Imperva / DataDome / Botprotect.io 等反僵尸服务,

自动下载驱动程序二进制文件并对其进行修补。

v8env

适用于 Python 的最小的现代嵌入式 V8 引擎 作用: 执行js脚本

报错

问题: Python 3.7以下版本 SyntaxError: future feature annotations is not defined

解决方法: 直接注释掉 # from future import annotations 即可

问题: selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:52693 from session not created: This version of ChromeDriver only supports Chrome version xxx Current browser version is 92.0.4515.159

解决方法: wirebrowserenv_uc.py 中 修改 version_main=xxx, # 注意填写自己浏览器版本 例如 version_main=92

感谢

Core symbols most depended-on inside this repo

i
called by 53
examples/example-v8env/bilibili_login.js
get
called by 43
jsenv/nodeenv/execjs.py
call
called by 23
v8env/py_mini_racer/py_mini_racer.py
he
called by 19
examples/example-v8env/bilibili_login.js
o
called by 9
examples/example-v8env/bilibili_login.js
c
called by 8
examples/example-v8env/bilibili_login.js
runtime_evaluate_script
called by 7
chrome_remote_pro/client.py
e
called by 7
examples/example-v8env/bilibili_login.js

Shape

Function 150
Method 150
Class 45

Languages

Python62%
TypeScript38%

Modules by API surface

examples/example-v8env/bilibili_login.js131 symbols
v8env/py_mini_racer/py_mini_racer.py42 symbols
jsenv/nodeenv/execjs.py17 symbols
jsenv/nodeenv/async_execjs.py17 symbols
chrome_remote_pro/client.py14 symbols
browserenv/env.py10 symbols
examples/example_httpbin_pro.py9 symbols
examples/example_SF.py9 symbols
browserenv/wirebrowserenv.py9 symbols
chrome_remote_pro/server.py8 symbols
jsenv/nodeenv/jsjson.py7 symbols
jsenv/nodeenv/jsdom.py7 symbols

For agents

$ claude mcp add Browser-Env \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page