browser-ai-cli 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,188 @@
1
+ {
2
+ "_说明": "AI站点配置文件 - 复制本文件为 ai_sites.json 并按需修改。所有站点路径相对本目录的 profiles/ 下。",
3
+ "_documentation": "AI site configuration. Copy this file to ai_sites.json and edit as needed. Profile directories live under ./profiles/<site_name>/.",
4
+ "_字段说明 / field reference": {
5
+ "name": "站点唯一标识(英文,用于profile目录名) / unique site ID (English, used as profile directory name)",
6
+ "display_name": "显示名称(中文/任意) / display name shown to humans",
7
+ "url": "站点入口URL / entry URL",
8
+ "login_url": "登录页URL / login URL (used for first-time login)",
9
+ "login_hint": "登录提示 / hint shown to the user during login",
10
+ "capabilities": "能力列表 / capability list: search=搜索, summarize=总结, chat=对话, file_upload=文件上传, video_ai=视频AI理解",
11
+ "selectors": {
12
+ "input": "输入框CSS选择器 / input box CSS selector",
13
+ "submit": "提交按钮CSS选择器 / submit button CSS selector",
14
+ "response": "响应内容容器CSS选择器 / response container CSS selector"
15
+ },
16
+ "special": "特殊处理标记 / special handler tag",
17
+ "enabled": "是否启用 / enabled",
18
+ "preferred_engine": "首选引擎 / preferred engine: chromium(登录态持久化 / persistent profile) / camoufox(反检测强 / strong anti-detect)",
19
+ "cookie_domains": "用于Firefox批量导入时匹配的域名列表 / domains used to match Firefox cookies during batch import"
20
+ },
21
+ "_添加新站点示例 / example new site": {
22
+ "name": "my_ai",
23
+ "display_name": "我的AI",
24
+ "url": "https://my-ai.com/",
25
+ "login_url": "https://my-ai.com/login",
26
+ "login_hint": "用手机号登录 / login with phone number",
27
+ "capabilities": ["chat"],
28
+ "selectors": {
29
+ "input": "textarea",
30
+ "submit": "button[type='submit']",
31
+ "response": "div.answer"
32
+ },
33
+ "special": null,
34
+ "enabled": true
35
+ },
36
+ "sites": [
37
+ {
38
+ "name": "yuanbao",
39
+ "display_name": "腾讯元宝 / Tencent Yuanbao",
40
+ "url": "https://yuanbao.tencent.com/chat",
41
+ "login_url": "https://yuanbao.tencent.com/",
42
+ "login_hint": "点击右上角登录,用微信或QQ扫码登录 / login with WeChat or QQ",
43
+ "capabilities": ["search", "summarize", "chat", "file_upload", "weixin_bypass"],
44
+ "selectors": {
45
+ "input": "textarea[placeholder*='输入'], textarea[placeholder*='问'], div[contenteditable='true']",
46
+ "submit": "button[type='submit'], button[aria-label*='发送'], button[class*='send']",
47
+ "response": "div[class*='answer'], div[class*='message'], div[class*='content']"
48
+ },
49
+ "special": "weixin_bypass",
50
+ "enabled": true,
51
+ "preferred_engine": "chromium",
52
+ "cookie_domains": [".tencent.com", "yuanbao.tencent.com"]
53
+ },
54
+ {
55
+ "name": "kimi",
56
+ "display_name": "Kimi(月之暗面 / Moonshot AI)",
57
+ "url": "https://kimi.moonshot.cn/chat",
58
+ "login_url": "https://kimi.moonshot.cn/",
59
+ "login_hint": "点击登录,可用手机号或微信扫码 / login with phone or WeChat",
60
+ "capabilities": ["search", "summarize", "chat", "file_upload"],
61
+ "selectors": {
62
+ "input": "textarea[placeholder*='输入'], textarea.editor",
63
+ "submit": "button[type='submit'], button[aria-label*='发送'], div[class*='send-button']",
64
+ "response": "div[class*='chat-content'], div[class*='answer'], section[class*='message']"
65
+ },
66
+ "special": "long_text",
67
+ "enabled": true,
68
+ "preferred_engine": "chromium",
69
+ "cookie_domains": ["kimi.moonshot.cn", ".moonshot.cn"]
70
+ },
71
+ {
72
+ "name": "tongyi",
73
+ "display_name": "通义千问 / Tongyi Qianwen",
74
+ "url": "https://tongyi.aliyun.com/qianwen",
75
+ "login_url": "https://tongyi.aliyun.com/",
76
+ "login_hint": "右上角登录,用阿里账号或支付宝扫码 / login with Aliyun or Alipay",
77
+ "capabilities": ["search", "summarize", "chat", "file_upload"],
78
+ "selectors": {
79
+ "input": "textarea[placeholder*='输入'], textarea[id*='input'], div[contenteditable='true']",
80
+ "submit": "button[type='submit'], button[aria-label*='发送'], button[class*='send']",
81
+ "response": "div[class*='answer'], div[class*='message-content'], div[class*='bubble']"
82
+ },
83
+ "special": null,
84
+ "enabled": true,
85
+ "preferred_engine": "chromium",
86
+ "cookie_domains": ["tongyi.aliyun.com", ".aliyun.com"]
87
+ },
88
+ {
89
+ "name": "zhida",
90
+ "display_name": "知乎直答 / Zhida AI",
91
+ "url": "https://zhida.ai/",
92
+ "login_url": "https://zhida.ai/",
93
+ "login_hint": "用知乎账号登录 / login with Zhihu account",
94
+ "capabilities": ["search", "summarize", "chat"],
95
+ "selectors": {
96
+ "input": "textarea[placeholder*='输入'], textarea[placeholder*='问'], input[type='text']",
97
+ "submit": "button[type='submit'], button[aria-label*='搜索'], button[class*='send']",
98
+ "response": "div[class*='answer'], div[class*='result'], div[class*='content']"
99
+ },
100
+ "special": "knowledge_qa",
101
+ "enabled": true,
102
+ "preferred_engine": "chromium",
103
+ "cookie_domains": ["zhida.ai", ".zhida.ai"]
104
+ },
105
+ {
106
+ "name": "bili_ai",
107
+ "display_name": "B站AI搜索 / Bilibili AI Search",
108
+ "url": "https://search.bilibili.com/all",
109
+ "login_url": "https://passport.bilibili.com/login",
110
+ "login_hint": "用B站账号登录 / login with Bilibili account",
111
+ "capabilities": ["search", "video_ai"],
112
+ "selectors": {
113
+ "input": "input.search-keyword, input[placeholder*='搜索']",
114
+ "submit": "button.search-btn, button[type='submit']",
115
+ "response": "div.video-list, div.search-result, div.bili-video-card"
116
+ },
117
+ "special": "video_search",
118
+ "enabled": true,
119
+ "preferred_engine": "chromium",
120
+ "cookie_domains": ["bilibili.com", ".bilibili.com"]
121
+ },
122
+ {
123
+ "name": "doubao",
124
+ "display_name": "豆包 / Doubao",
125
+ "url": "https://www.doubao.com/",
126
+ "login_url": "https://www.doubao.com/",
127
+ "login_hint": "用手机号、抖音号或验证码登录 / login with phone, Douyin ID, or SMS code",
128
+ "capabilities": ["search", "chat", "video_ai"],
129
+ "selectors": {
130
+ "input": "textarea[placeholder*='输入'], textarea[placeholder*='问'], div[contenteditable='true']",
131
+ "submit": "button[type='submit'], button[aria-label*='发送'], button[class*='send']",
132
+ "response": "div[class*='answer'], div[class*='message-content'], div[class*='chat-content']"
133
+ },
134
+ "special": "douyin_video_search",
135
+ "enabled": true,
136
+ "preferred_engine": "chromium",
137
+ "cookie_domains": ["doubao.com", ".doubao.com", ".bytedance.com"]
138
+ },
139
+ {
140
+ "name": "sogou_weixin",
141
+ "display_name": "搜狗微信搜索(公众号专用) / Sogou WeChat Search",
142
+ "url": "https://weixin.sogou.com/",
143
+ "login_url": "https://weixin.sogou.com/",
144
+ "login_hint": "无需登录,直接使用 / no login required",
145
+ "capabilities": ["search"],
146
+ "selectors": {
147
+ "input": "input#query, input[name='query']",
148
+ "submit": "input#swz, button[type='submit'], a#swz",
149
+ "response": "div.results, div.txt-box, div[class*='news-box']"
150
+ },
151
+ "special": "weixin_search",
152
+ "enabled": true,
153
+ "preferred_engine": "camoufox"
154
+ },
155
+ {
156
+ "name": "baidu",
157
+ "display_name": "百度搜索 / Baidu Search",
158
+ "url": "https://www.baidu.com/",
159
+ "login_url": "https://www.baidu.com/",
160
+ "login_hint": "无需登录 / no login required",
161
+ "capabilities": ["search"],
162
+ "selectors": {
163
+ "input": "input#kw, input[name='wd']",
164
+ "submit": "input#su, button[type='submit']",
165
+ "response": "div#content_left, div.result, div[class*='result']"
166
+ },
167
+ "special": null,
168
+ "enabled": true,
169
+ "preferred_engine": "camoufox"
170
+ },
171
+ {
172
+ "name": "google",
173
+ "display_name": "Google搜索 / Google Search",
174
+ "url": "https://www.google.com/",
175
+ "login_url": "https://www.google.com/",
176
+ "login_hint": "无需登录 / no login required",
177
+ "capabilities": ["search"],
178
+ "selectors": {
179
+ "input": "input[name='q'], textarea[name='q']",
180
+ "submit": "button[type='submit'], button[aria-label*='Search']",
181
+ "response": "div#search, div.g, div[class*='g']"
182
+ },
183
+ "special": null,
184
+ "enabled": true,
185
+ "preferred_engine": "camoufox"
186
+ }
187
+ ]
188
+ }
@@ -0,0 +1,111 @@
1
+ {
2
+ "_说明": "智能搜索路由规则 - 定义任务类型→搜索源的映射。支持并行试探+质量评估+深度搜索。",
3
+ "_documentation": "Smart search routing. Maps a task type to one or more probe sources. Used by `python browser_ai.py search`.",
4
+ "_策略说明 / strategy notes": {
5
+ "probe": "试探阶段:并行查询多个源,每个源只取前3-5条结果 / probe stage: query multiple sources in parallel, take top 3-5 each",
6
+ "evaluate": "评估阶段:根据结果数量、相关性、独家信息量打分 / evaluate by count, relevance, unique content",
7
+ "deep_dive": "深度阶段:对高分源进行深度查询 / deep dive on high-scoring sources"
8
+ },
9
+ "routes": [
10
+ {
11
+ "task_type": "weixin_article",
12
+ "description": "公众号文章搜索 / WeChat public-account article search",
13
+ "trigger_keywords": ["公众号", "微信文章", "wechat article", "公众号文章"],
14
+ "probe_sources": [
15
+ {"site": "sogou_weixin", "weight": 1.0, "reason": "搜狗微信搜索专搜公众号,覆盖率最高 / sogou is the main aggregator"},
16
+ {"site": "yuanbao", "weight": 0.9, "reason": "元宝可联网搜索公众号内容并总结 / yuanbao can web-search and summarize"},
17
+ {"site": "baidu", "weight": 0.5, "reason": "百度可能搜到转载,但非原站 / baidu finds reprints only"},
18
+ {"site": "google", "weight": 0.4, "reason": "Google对公众号索引有限 / google indexes wechat poorly"}
19
+ ],
20
+ "deep_dive_sources": ["yuanbao", "kimi"],
21
+ "deep_dive_action": "将搜狗找到的文章URL喂给元宝/Kimi总结 / feed urls to yuanbao or kimi for summary"
22
+ },
23
+ {
24
+ "task_type": "general_search",
25
+ "description": "通用搜索 / general search",
26
+ "trigger_keywords": [],
27
+ "probe_sources": [
28
+ {"site": "baidu", "weight": 0.8, "reason": "中文内容覆盖好 / best Chinese coverage"},
29
+ {"site": "google", "weight": 0.9, "reason": "综合质量最高 / overall quality"},
30
+ {"site": "yuanbao", "weight": 0.7, "reason": "AI总结能力强 / strong AI summarization"}
31
+ ],
32
+ "deep_dive_sources": ["yuanbao", "kimi"],
33
+ "deep_dive_action": "让AI总结搜索结果 / let an AI summarize results"
34
+ },
35
+ {
36
+ "task_type": "tech_question",
37
+ "description": "技术问题 / technical question",
38
+ "trigger_keywords": ["代码", "bug", "error", "编程", "开发", "API", "框架", "code", "programming", "framework"],
39
+ "probe_sources": [
40
+ {"site": "google", "weight": 1.0, "reason": "技术内容索引最好 / best tech indexing"},
41
+ {"site": "yuanbao", "weight": 0.8, "reason": "可总结技术文档 / can summarize docs"},
42
+ {"site": "kimi", "weight": 0.7, "reason": "可读长文档 / reads long docs well"}
43
+ ],
44
+ "deep_dive_sources": ["kimi", "tongyi"],
45
+ "deep_dive_action": "把技术文档喂给Kimi读全文并总结 / feed docs to kimi"
46
+ },
47
+ {
48
+ "task_type": "knowledge_qa",
49
+ "description": "知识问答 / knowledge Q&A",
50
+ "trigger_keywords": ["是什么", "为什么", "怎么样", "如何", "区别", "what is", "why", "how"],
51
+ "probe_sources": [
52
+ {"site": "zhida", "weight": 1.0, "reason": "知乎直答专做知识问答 / zhida is purpose-built"},
53
+ {"site": "yuanbao", "weight": 0.9, "reason": "联网搜索+总结 / web search + summarize"},
54
+ {"site": "tongyi", "weight": 0.8, "reason": "通义千问知识面广 / tongyi has broad coverage"}
55
+ ],
56
+ "deep_dive_sources": ["zhida", "yuanbao"],
57
+ "deep_dive_action": "对比多个AI的答案,取共识+补充差异 / compare AI answers"
58
+ },
59
+ {
60
+ "task_type": "video_content",
61
+ "description": "视频内容理解 / video content understanding",
62
+ "trigger_keywords": ["视频", "B站", "bilibili", "抖音", "讲什么", "video", "douyin"],
63
+ "probe_sources": [
64
+ {"site": "bili_ai", "weight": 1.0, "reason": "B站原生搜索 / native bilibili search"},
65
+ {"site": "doubao", "weight": 0.95, "reason": "豆包可检索抖音视频并总结 / doubao can search douyin"}
66
+ ],
67
+ "deep_dive_sources": ["doubao", "kimi"],
68
+ "deep_dive_action": "让豆包直接检索抖音视频并总结,或把视频链接喂给Kimi / doubao search, kimi summarize"
69
+ },
70
+ {
71
+ "task_type": "long_text",
72
+ "description": "长文本处理 / long-text processing",
73
+ "trigger_keywords": ["总结", "摘要", "读一下", "这篇", "文档", "summarize", "summary", "read"],
74
+ "probe_sources": [
75
+ {"site": "kimi", "weight": 1.0, "reason": "Kimi长文本能力最强 / kimi is the strongest"},
76
+ {"site": "tongyi", "weight": 0.8, "reason": "通义也支持长文本 / tongyi also supports long text"}
77
+ ],
78
+ "deep_dive_sources": ["kimi"],
79
+ "deep_dive_action": "直接喂给Kimi读全文 / feed to kimi"
80
+ },
81
+ {
82
+ "task_type": "news",
83
+ "description": "新闻资讯 / news",
84
+ "trigger_keywords": ["新闻", "最新", "今天", "近期", "发生", "news", "today", "recent"],
85
+ "probe_sources": [
86
+ {"site": "baidu", "weight": 0.9, "reason": "百度新闻实时性好 / baidu news is fresh"},
87
+ {"site": "yuanbao", "weight": 1.0, "reason": "元宝联网搜索+总结 / yuanbao web + summary"},
88
+ {"site": "google", "weight": 0.7, "reason": "Google News / google news"}
89
+ ],
90
+ "deep_dive_sources": ["yuanbao"],
91
+ "deep_dive_action": "让元宝总结新闻要点 / yuanbao summary"
92
+ }
93
+ ],
94
+ "default_route": {
95
+ "task_type": "general_search",
96
+ "description": "默认路由:无法识别任务类型时使用 / fallback route",
97
+ "probe_sources": [
98
+ {"site": "baidu", "weight": 0.8},
99
+ {"site": "google", "weight": 0.9},
100
+ {"site": "yuanbao", "weight": 0.7}
101
+ ],
102
+ "deep_dive_sources": ["yuanbao", "kimi"]
103
+ },
104
+ "quality_scoring": {
105
+ "result_count_weight": 0.2,
106
+ "relevance_weight": 0.4,
107
+ "unique_info_weight": 0.3,
108
+ "source_authority_weight": 0.1,
109
+ "deep_dive_threshold": 0.6
110
+ }
111
+ }
@@ -0,0 +1,315 @@
1
+ Metadata-Version: 2.4
2
+ Name: browser-ai-cli
3
+ Version: 0.1.0
4
+ Summary: Multi-site AI aggregator CLI for Chinese AI products and search engines (Yuanbao, Kimi, Tongyi, Doubao, Baidu, Sogou WeChat, ...).
5
+ Author-email: Weiming3 <weiming3@users.noreply.github.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Weiming
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Homepage, https://github.com/Weiming3/browser-ai
28
+ Project-URL: Issues, https://github.com/Weiming3/browser-ai/issues
29
+ Project-URL: Source code, https://github.com/Weiming3/browser-ai
30
+ Keywords: playwright,camoufox,browser-automation,ai-router,ai-aggregator,chinese-ai,wechat-search
31
+ Platform: any
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Environment :: Console
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: OS Independent
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3.9
39
+ Classifier: Programming Language :: Python :: 3.10
40
+ Classifier: Programming Language :: Python :: 3.11
41
+ Classifier: Programming Language :: Python :: 3.12
42
+ Classifier: Programming Language :: Python :: 3.13
43
+ Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
44
+ Classifier: Topic :: Utilities
45
+ Requires-Python: >=3.9
46
+ Description-Content-Type: text/markdown
47
+ License-File: LICENSE
48
+ Requires-Dist: playwright>=1.40.0
49
+ Requires-Dist: camoufox>=0.4.0
50
+ Dynamic: license-file
51
+
52
+ <p align="center">
53
+ <span>>简体中文<</span>
54
+ &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
55
+ <a href="README_en.md" lang="en" hreflang="en">English</a>
56
+ </p>
57
+
58
+ # Browser-AI Toolkit / 浏览器 AI 工具集
59
+
60
+ <p align="center">
61
+ <img src="https://stone.professorlee.work/api/stone/Weiming3/browser-ai" alt="Stone Badge">
62
+ </p>
63
+
64
+ > 一个 CLI,把同一句话同时丢给一堆 AI 和搜索引擎,然后把答案排好序端回来。
65
+
66
+ [![Python](https://img.shields.io/badge/python-3.9%2B-blue)](https://www.python.org/)
67
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
68
+ [![Playwright](https://img.shields.io/badge/powered%20by-playwright-green)](https://playwright.dev/)
69
+
70
+ ---
71
+
72
+ ## 这是干嘛的?
73
+
74
+ `browser-ai` 是一个 Python CLI:把单条查询同时分发给多个 AI 服务(腾讯元宝、Kimi、通义千问、知乎直答、豆包……)和搜索引擎(百度、Google、搜狗微信),等所有源返回后做统一排序,输出一个综合结果。
75
+
76
+ 底层基于 Playwright,提供两个可按站点切换的引擎:
77
+
78
+ - **Chromium + 持久化 profile**:用于需要保留登录态的站点。
79
+ - **Camoufox**(反检测 Firefox):用于对普通浏览器进行指纹识别的搜索/抓取类站点。
80
+
81
+ 站点配置完全由 `config/ai_sites.json` 数据驱动。新增站点只需复制一段配置并修改选择器,**无需改动任何 Python 代码**。
82
+
83
+ ---
84
+
85
+ ## 和 OpenRouter / LiteLLM 有什么不同?
86
+
87
+ 看到这里第一反应很可能是「这不就是又一个 AI router 吗?」——问题合理,但**路由对象完全不同**。
88
+
89
+ | | OpenRouter / LiteLLM / OneAPI / Portkey | browser-ai |
90
+ |---|---|---|
91
+ | 路由对象 | LLM **API 端点** | AI **网页产品** + **搜索引擎网页** |
92
+ | 调用方式 | HTTP API(OpenAI 兼容格式) | 浏览器自动化(Playwright) |
93
+ | 鉴权 | API Key(按 token 计费) | 你自己的**登录态**(cookie / persistent profile) |
94
+ | 覆盖范围 | 有公开 API 的 LLM 提供商 | 有网页 UI 的一切——**包括没 API 的** |
95
+ | 输出 | 单个模型的文本回复 | 多源页面文本 + **统一打分排序** |
96
+ | 形态 | 后端服务 / 网关 | 本地 CLI |
97
+
98
+ API router 做不到的三件事,`browser-ai` 都覆盖:
99
+
100
+ **1. 那些「没 API、只有网页」的源。**
101
+
102
+ 腾讯元宝、知乎直答、Web 版豆包、B 站 AI 总结、搜狗微信——这些都没有公开 API,但都是有用信源。API router 物理上摸不到这一层。
103
+
104
+ **2. 主流 LLM 看不到的「围墙花园」内容。**
105
+
106
+ Gemini、GPT、Claude 这类模型有训练截止日期,而且语料重度偏向英文。它们对中文平台围墙内的内容覆盖非常弱:
107
+
108
+ - **微信公众号**:中文长文的主战场,Google 几乎索引不到,模型训练数据里也稀薄。
109
+ - **百度贴吧、知乎、小红书**:反爬严格、登录门槛高,西方爬虫根本看不见。
110
+ - **中文平台的实时内容**:上周刚发的帖子、新出的爆款文章,模型压根没见过。
111
+
112
+ `browser-ai` 通过搜狗微信(目前唯一的公开公众号聚合入口)、百度、加上你登录好的元宝 / Kimi 会话,**直接抓活的、带中文场景的真实资料**,而不是问一个 LLM 它几年前的记忆。`weixin` 命令就是为这个场景设计的——搜狗 + 百度 + 元宝三路包抄同一个查询,把 AI 看不到的中文长文搜回来,**给 LLM 的回答补充一个它够不着的思考维度**。
113
+
114
+ **3. AI + 搜索引擎混合扇出。**
115
+
116
+ 大多数 AI router 只在 LLM 之间扇出。`browser-ai` 把 AI 产品和搜索引擎(百度、Google、搜狗微信)混在同一次查询里——这是「边问 AI、边找参考资料」的唯一实用做法。
117
+
118
+ **一句话总结**:OpenRouter 做的是「**API 抽象层**」;`browser-ai` 做的是「**网页抽象层**」——把任何带网页的 AI 产品或搜索引擎,捏成一个统一查询目标。
119
+
120
+ ---
121
+
122
+ ## 和 `@playwright/mcp` 有什么不同?
123
+
124
+ > `@playwright/mcp` 是微软官方维护的 Playwright MCP 服务器:把浏览器自动化能力暴露成 MCP 工具,让 AI agent 可以一步步指挥浏览器。
125
+
126
+ 它和 `browser-ai` **不在同一个层面竞争**——一个把浏览器暴露给 AI,另一个是基于浏览器的预设工作流。
127
+
128
+ | | `@playwright/mcp` | browser-ai |
129
+ |---|---|---|
130
+ | 本质 | 通用浏览器遥控器(MCP 工具集) | 预设工作流 CLI |
131
+ | 决策者 | AI agent 自己(一步步操作) | JSON 配置(开箱即用) |
132
+ | 执行模式 | 单标签页串行 | 多站点并行扇出(`asyncio.gather`) |
133
+ | 站点知识 | 通用,每次让 AI 现场摸索 | 预配每个 AI 站点的选择器 / 等待逻辑 |
134
+ | 反检测 | 无 | `navigator.webdriver` 掩蔽 + 可选 Camoufox |
135
+ | 登录态 | 无 explicit 管理 | `config/profiles/` 按站点分目录 + Firefox cookie 导入 |
136
+ | 意图路由 | 无 | `search_routes.json` 按关键词决定探哪些站点 |
137
+ | 评分排序 | 无 | 三阶段 probe → evaluate → deep-dive |
138
+ | 公众号搜索 | 无 | `weixin` 命令三路包抄 |
139
+
140
+ **一句话总结**:
141
+
142
+ > `@playwright/mcp` 给 AI agent 一本**空白笔记本和一支笔**;`browser-ai` 是已经填好的**答题卡**,连笔迹都描过一遍了。
143
+
144
+ ### 推荐两者都装
145
+
146
+ 它们解决的问题不同,建议都装:
147
+
148
+ ```bash
149
+ # browser-ai:CLI 工作流(多源聚合、反检测、预配站点)
150
+ pip install playwright camoufox
151
+ playwright install chromium
152
+ camoufox fetch
153
+
154
+ # @playwright/mcp:MCP 工具集(让 Claude / Cursor / Cline 直接控制浏览器)
155
+ npm install -g @playwright/mcp
156
+ ```
157
+
158
+ - `@playwright/mcp` 适合「**让 AI 自由探索新站点**」的开放场景。
159
+ - `browser-ai` 适合「**中文 AI 产品聚合 + 围墙花园数据获取**」的预设场景。
160
+
161
+ 两个装上互不冲突,按场景切换用。
162
+
163
+ ---
164
+
165
+ ## 快速开始
166
+
167
+ ### 方式一:`pip install`(推荐给最终用户)
168
+
169
+ ```bash
170
+ pip install browser-ai-cli
171
+ playwright install chromium
172
+
173
+ # 可选:反检测场景用得到
174
+ camoufox fetch
175
+
176
+ # 首次运行会自动把模板配置拷到 ~/.config/browser-ai/config/
177
+ browser-ai-cli list
178
+
179
+ # 登录某个站点(会弹一个真的浏览器窗口,自己手动登录一下就行)
180
+ browser-ai-cli login yuanbao
181
+
182
+ # 全网智能搜索:AI + 搜索引擎一起上
183
+ browser-ai-cli search "python 异步编程最佳实践"
184
+
185
+ # 公众号文章:搜狗 + 百度 + 元宝三路包抄
186
+ browser-ai-cli weixin "微信公众号 跨境电商"
187
+ ```
188
+
189
+ > pip 安装模式下,配置和登录态落在 `~/.config/browser-ai/`(XDG 风格),和系统其他 dotfiles 一处管理。本地 checkout 模式下仍是仓库根目录的 `config/`,老用户行为不变。
190
+
191
+ ### 方式二:clone 仓库自己改(推荐给二次开发)
192
+
193
+ ```bash
194
+ git clone https://github.com/Weiming3/browser-ai.git
195
+ cd browser-ai
196
+ pip install -r requirements.txt
197
+ playwright install chromium
198
+
199
+ # 可选:装上 Camoufox,反检测场景用得到
200
+ pip install camoufox
201
+ camoufox fetch
202
+
203
+ # 把示例配置复制成你自己的本地配置
204
+ cp config/ai_sites.example.json config/ai_sites.json
205
+ cp config/search_routes.example.json config/search_routes.json
206
+
207
+ # 看看现在接了哪些站点
208
+ python scripts/browser_ai.py list
209
+
210
+ # 登录某个站点(会弹一个真的浏览器窗口,自己手动登录一下就行)
211
+ python scripts/browser_ai.py login yuanbao
212
+
213
+ # 全网智能搜索:AI + 搜索引擎一起上
214
+ python scripts/browser_ai.py search "python 异步编程最佳实践"
215
+
216
+ # 想单独戳某个源也行
217
+ python scripts/browser_ai.py probe "kimi 长文本"
218
+ ```
219
+
220
+ ---
221
+
222
+ ## 从 Firefox 导入已有登录态
223
+
224
+ 如果某些站点你已经在 Firefox 里登录过,不必再手动登录一次。`scripts/import_firefox_login.py` 会读取你本机 Firefox 的 `cookies.sqlite` 数据库,把对应的 cookie 写入到 `config/profiles/` 下对应的 Chromium profile 目录中。
225
+
226
+ ```bash
227
+ # 先 dry-run 看看会动哪些 cookie
228
+ python scripts/import_firefox_login.py --dry-run
229
+
230
+ # 确认无误后再真跑
231
+ python scripts/import_firefox_login.py
232
+
233
+ # 只导入某个站点的 cookie
234
+ python scripts/import_firefox_login.py --site yuanbao
235
+ ```
236
+
237
+ 强烈建议第一次使用先跑 `--dry-run` 预览。
238
+
239
+ ---
240
+
241
+ ## 目录结构
242
+
243
+ ```
244
+ browser-ai/
245
+ ├── scripts/
246
+ │ ├── browser_ai.py # 主 CLI
247
+ │ ├── import_firefox_login.py # Firefox 登录态搬运工
248
+ │ └── pre-commit-check.py # 提交前安全检查
249
+ ├── config/
250
+ │ ├── ai_sites.example.json # 模板,复制成 ai_sites.json
251
+ │ └── search_routes.example.json
252
+ ├── tests/
253
+ │ └── test_smoke.py # 26 个冒烟测试
254
+ ├── README.md
255
+ ├── README_en.md
256
+ ├── LICENSE
257
+ ├── pyproject.toml # pip 包元数据 + entry point
258
+ ├── requirements.txt
259
+ ├── .gitignore
260
+ └── .gitattributes
261
+ ```
262
+
263
+ ---
264
+
265
+ ## 加一个新 AI 站点
266
+
267
+ 最快是跑向导:
268
+
269
+ ```bash
270
+ python scripts/browser_ai.py add-site
271
+ ```
272
+
273
+ 愿意直接改 JSON 的话,从 `config/ai_sites.json` 里复制一段 site,改这几个字段就够了:`name`、`url`、`login_url`、`login_hint`、`selectors.input`、`selectors.submit`、`selectors.response`、`preferred_engine`。重启 CLI,新站点就上线了。
274
+
275
+ ---
276
+
277
+ ## 引擎怎么选?
278
+
279
+ | 引擎 | 适用场景 |
280
+ |------|----------|
281
+ | Chromium + profile | 需要登录态的站点(元宝、Kimi、豆包、B站)。 |
282
+ | Camoufox | 搜索/抓取类站点对无头 Chromium 不友好(百度、Google、搜狗微信)。 |
283
+
284
+ 在 `ai_sites.json` 里给每个站点设一个 `preferred_engine` 就完事,**只这一个开关**。两个引擎相互独立——想留就留,想拆就拆,反正不是承重墙。
285
+
286
+ ---
287
+
288
+ ## 真正要看两眼的就这两件事
289
+
290
+ **一、登录态别往仓库里塞。**
291
+
292
+ `config/profiles/` 里装的是 cookies、localStorage、IndexedDB,基本等同于每个站点的活动登录会话。`.gitignore` 默认已经把它排除在外了,**别动这一行**。真正的 `config/ai_sites.json` 也在 gitignore 里,模板是 `*.example.json` 那两份。仓库自带的 `scripts/pre-commit-check.py` 会拦下任何想偷偷把这俩文件加进去的 commit。建议这样用:
293
+
294
+ ```bash
295
+ python scripts/pre-commit-check.py # 每次提交前手动跑
296
+ cp scripts/pre-commit-check.py .git/hooks/pre-commit # 装成 git hook 自动拦截
297
+ ```
298
+
299
+ **二、站点的服务条款还是老大。**
300
+
301
+ 绝大多数 AI 平台的服务条款都明确禁止自动化访问。本工具就自己研究用,别拿去当爬虫服务赚钱,也别去薅别人的付费内容。被限流、被封 IP、被发律师函,都跟作者没关系,谢谢。
302
+
303
+ ---
304
+
305
+ ## 一些零碎
306
+
307
+ - `login` 和 `--headed` 一定弹窗,其他命令默认静默。
308
+ - 百度/Google 无头模式有时候会跳验证码,加 `--headed` 就行。
309
+ - 默认配置是样例,**不是真理**。按自己工作流改好再发给别人看。
310
+
311
+ ---
312
+
313
+ ## 许可证
314
+
315
+ MIT —— 见 [LICENSE](LICENSE)。
@@ -0,0 +1,12 @@
1
+ browser_ai_cli-0.1.0.data/data/browser_ai_examples/ai_sites.example.json,sha256=GLQqRgorlNo4DEvfX9SuoFjeqGFCEN3yJRevWnKXCdk,8559
2
+ browser_ai_cli-0.1.0.data/data/browser_ai_examples/search_routes.example.json,sha256=52uXtuSav6qq0YoRCPkv5BHs3of3GR7PNxp2kYSvdgs,6081
3
+ browser_ai_cli-0.1.0.dist-info/licenses/LICENSE,sha256=VFcgtGlefSn5dCufuTGUcTkC9qiaYTQdU8oaifH0634,1063
4
+ scripts/__init__.py,sha256=phF_ZGzviP7FtHvxsLkAc0gb2OPHRSLxgkOWU9ySXWM,253
5
+ scripts/browser_ai.py,sha256=aycVUsa37toUJ-XEI3i6TR4WeA_roVtpefTNpWeiIZA,29145
6
+ scripts/import_firefox_login.py,sha256=XSv4KzyHqJ--TU_Aqj4kA1pFhDmn93B_eJDBY4XW1vI,17767
7
+ scripts/pre-commit-check.py,sha256=6Uiqb4IHYkXE7NbSdVr3OS7ZKlx8Wi2YbovVNhurDiA,5906
8
+ browser_ai_cli-0.1.0.dist-info/METADATA,sha256=i4ecsF4UuY-pbTZX3D1BfrgfunZgMZ4C2qEiCCzWad0,13587
9
+ browser_ai_cli-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
10
+ browser_ai_cli-0.1.0.dist-info/entry_points.txt,sha256=Zs2eP03QShY3AjJuOin9aLFyZOa5vJYKi-diS_LkHlo,59
11
+ browser_ai_cli-0.1.0.dist-info/top_level.txt,sha256=rmzd5mewlrJy4sT608KPib7sM7edoY75AeqJeY3SPB4,8
12
+ browser_ai_cli-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ browser-ai-cli = scripts.browser_ai:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Weiming
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ scripts