15 Commits
Author SHA1 Message Date
hz4th_coder 17431e86cf v1.7.4 auto 默认顺序改为优先 playwright、其次 agent-browser
- 按大爷要求调整: auto 优先 playwright(Python, domcontentloaded更宽容), 其次 agent-browser(Rust)
- capture_webpage + smart_capture 的 auto 选路同步调整
- 新增对称兜底: playwright 失败自动切 agent-browser 重试(原 agent-browser超时→playwright 逻辑保留)
- /api/backends 与前端选择器说明同步更新(auto label/priority)
2026-08-31 17:23:01 +08:00
hz4th_coder 82ff8a2610 v1.7.3 前端新增后端选择器 + 暴露 /api/backends + 接通 chrome-cdp 后端
- 新增 GET /api/backends 返回可用后端/默认顺序/说明,供前端动态渲染
- 前端表单新增「捕获后端」下拉框: 自动(默认,优先agent-browser超时自动回退playwright)/agent-browser/playwright/chrome-cdp,不可用的置灰
- 接通 chrome-cdp 后端: 之前函数已实现但 capture_webpage 未接线(传 backend=chrome-cdp 会报 Unknown backend),现支持 screenshot/html/text,连接已开的 Chrome(--remote-debugging-port)
- 前端 currentData 携带 backend 字段
2026-08-31 16:56:22 +08:00
hz4th_coder 1e69e7ca57 v1.7.2 修复慢加载页面报 'Operation timed out':agent-browser 打开超时自动切 Playwright 重试
- 根因: agent-browser open 导航内部超时约30s(CDP command timed out: Page.navigate),慢加载/持续加载页面(如资源挂起导致 load 事件永不触发)会报 Failed to open URL: Operation timed out
- agent-browser open 子进程超时 30s→45s,让其返回自己的超时报错而非被硬杀
- 超时判定放宽到 timed out/timeout 全变体,触发自动回退: capture_webpage 与 smart_capture 在 agent-browser 打开超时时自动切 Playwright 重试(domcontentloaded 更宽容,不等全部资源)
- Playwright goto domcontentloaded 超时 30s→60s
- 错误提示更友好(说明慢加载+已自动回退+建议)
- 实测: 挂起资源测试页 agent-browser 超时→playwright 成功, 耗时~39s; 正常页面无回归
2026-08-31 16:51:17 +08:00
hz4th_coder 951f941eee v1.7.1 修复前端捕获报错: fetch headers 不允许非 ISO-8859-1 字符(中文'游客'导致 Failed to read headers)
- 前端 /api/capture 请求头去掉 X-Caller: '游客'(中文在 HTTP 头非法,浏览器 fetch 直接抛错)
- 保留 X-From: web(ASCII 安全),调用者缺省由服务端默认 游客,行为不变
2026-08-31 16:27:04 +08:00
hz4th_coder 9c63887e10 v1.7.0 历史记录标注调用者/调用方式 + 每次提取自动按月归档原始HTML + 修复agent-browser HTML JSON转义bug
- 历史记录新增 caller(调用者: 游客/项目名) 与 call_method(调用方式: web/api)
  * 请求体 caller 或请求头 X-Caller/X-Project/X-App 标识调用者, 默认游客
  * 请求体 call_method 或 X-From 标识方式, 缺省按 Referer 自动判定(本前端=web, 否则api)
  * 前端提取请求带 X-From:web / X-Caller:游客; news-tracker 调用带 caller=news-tracker
- 每次提取后自动保存最原始 HTML 到 data/html/<YYYY-MM>/ 按月目录归档
  * screenshot/html/text/smart 四种动作均顺带抓取原始HTML并落盘
  * 历史详情新增 📄原始HTML文件 链接(GET /api/history/<id>/html), 删除记录连带删文件
- 修复: agent-browser 后端 html 提取返回 JSON 转义文本(非最原始HTML)的bug, 现解码为干净HTML
2026-08-31 13:12:22 +08:00
hz4th_coder e5ff90c46a 新增按需截图功能:滚动截图 + 视觉大模型实时判断
- 新 action=smart:每次截图后用视觉大模型判断主题内容是否已截全、是否还需向下滚动,自动滚动到判定完成,最后纵向拼接成长图
- 默认视觉模型 qwen3.6-plus(autodl),支持 agent-browser / playwright 双后端
- LLM 接口可网页配置:⚙️智能配置弹窗(base_url/api_key/model/提示词/最大滚动次数/滚动比例/超时) + 测试连接 + 持久化到 data/config.json
- 新增 API:GET/POST /api/smart/config、POST /api/smart/test
- 安全兜底:大模型判断失败保守停止、滚动位置不再变化判底部、最大滚动次数上限
- 历史新增 smart 类型:入库拼接长图+AI判断过程日志,详情弹窗可查看每一步截图判断
- 前端:智能模式提示条 + 结果展示拼接长图 + AI判断过程折叠查看 + 历史筛选/徽章/详情
2026-08-29 18:08:22 +08:00
hz4th_coder 2a9f187ce8 新增可读文本提取 + 历史记录分页管理
- 新增 text 动作:提取页面可读文本(innerText + 空行/行尾清理,剔除脚本样式标签),agent-browser 与 playwright 双后端支持,自动提取页面标题
- 提取历史持久化(SQLite WAL):每次捕获自动入库,截图文件存持久化目录
- 新增 API:GET /api/history(分页/类型筛选/搜索)、GET /api/history/<id>(详情)、GET /api/history/<id>/file(截图)、DELETE /api/history/<id>
- 前端:新增提取文本选项+干净文本展示;新增提取历史卡片(分页/筛选/搜索/查看弹窗/删除/下载/复制)
2026-08-29 17:37:43 +08:00
hz4th_coder f7f14d7114 恢复端口为16025 2026-07-07 13:23:36 +08:00
hz4th_coder ef4d26f11b 修改默认端口为16026 2026-07-07 13:20:52 +08:00
hz4th_coder fc43e6e806 优化等待设置,支持长时间验证过程
改进:
- 页面加载等待时间上限提高到 60秒
- 添加等待 networkidle 状态逻辑
- 前端界面增加等待设置说明
- 提示用户针对验证网站设置 10-30秒等待

使用场景:
- Cloudflare 等验证网站
- 复杂加载过程网站
- 需要用户确认的页面
2026-07-05 01:32:52 +08:00
hz4th_coder 5783feb60d 集成 playwright-stealth 专业反检测插件
添加:
- playwright-stealth 反检测库
- 增强 navigator 属性模拟
- 真实 Chrome 浏览器支持(如果已安装)
- 更强的反自动化检测配置

注意:
- 某些高防护网站(如 Cloudflare)仍可能拦截
- 建议使用代理或真实 Chrome 浏览器
2026-07-05 01:28:24 +08:00
hz4th_coder 98ef180878 增强 Playwright 反爬虫检测能力
添加:
- 禁用自动化控制特征
- 真实浏览器参数配置
- 反检测脚本注入
- 地理位置等真实特征
- 更强的 User-Agent 模拟

Playwright 后端可以更好地绕过反爬虫检测
2026-07-05 00:55:09 +08:00
hz4th_coder 6b7e856e38 增强 agent-browser 反爬虫支持
- 自动设置 AGENT_BROWSER_SOCKET_DIR 环境变量
- 添加真实 User-Agent 绕过反爬虫检测
- 增加 403 错误检测和提示
- 解决 techpowerup.com 等网站拦截问题
2026-07-05 00:19:18 +08:00
hz4th_coder ccb8479242 修复 agent-browser socket 目录权限问题
- 自动创建 /tmp/agent-browser-sockets 目录
- 设置 AGENT_BROWSER_SOCKET_DIR 环境变量
- 解决 Permission denied 错误
2026-07-05 00:12:48 +08:00
hz4th_coder 8f9bdff00c 修改部署端口为 16025
- Flask 服务端口: 16025
- Docker 端口映射: 16025:16025
- systemd 服务配置更新
- 测试脚本端口更新
- 文档示例更新
2026-07-04 23:21:52 +08:00
12 changed files with 2088 additions and 80 deletions
+3
View File
@@ -31,6 +31,9 @@ captures/
*.png
*.html
# 运行时数据(历史记录数据库 + 截图文件)
data/
# 环境变量
.env
.env.local
+3 -3
View File
@@ -49,10 +49,10 @@ COPY . .
# 创建临时目录
RUN mkdir -p /tmp/web_captures
EXPOSE 5000
EXPOSE 16025
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5000/health || exit 1
CMD curl -f http://localhost:16025/health || exit 1
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "--timeout", "120", "app:app"]
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:16025", "--timeout", "120", "app:app"]
+43
View File
@@ -0,0 +1,43 @@
# Web Capture API 项目
## 待推送信息
- **仓库地址**: http://121.40.164.32:12007/hz4th_coder/web-capture-api.git
- **当前版本**: v1.0.2
- **提交历史**:
- v1.0.0: 初始化项目
- v1.0.1: 修改端口为 16025
- v1.0.2: 修复 agent-browser socket 权限问题
## 操作步骤
### 1. 在 Git 平台创建仓库
请大爷登录 Git 平台 (http://121.40.164.32:12007) 并创建仓库:
- 仓库名称: `web-capture-api`
- 所属用户: `hz4th_coder`
- 可见性: 公开或私有(根据需要)
### 2. 推送代码
仓库创建后,运行以下命令:
```bash
cd /home/openclaw/.openclaw/workspace-hz4th_coder/works/web-capture-api
git push -u origin master --tags
```
## 项目功能
- 网页截图(全页或视口)
- HTML 代码提取
- 自动滚动加载动态内容
- 自定义视口大小
- Web 界面和 RESTful API
- 支持 agent-browser 和 Playwright 双后端
- Docker 部署支持
## 服务地址
- Web 界面: http://192.168.0.101:16025
- API 接口: http://192.168.0.101:16025/api/capture
+11 -11
View File
@@ -104,18 +104,18 @@ API 信息接口
```bash
# 基础截图
curl -X POST http://localhost:5000/api/capture \
curl -X POST http://localhost:16025/api/capture \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "action": "screenshot"}' \
--output screenshot.png
# 提取HTML
curl -X POST http://localhost:5000/api/capture \
curl -X POST http://localhost:16025/api/capture \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "action": "html"}'
# 滚动加载后全页截图
curl -X POST http://localhost:5000/api/capture \
curl -X POST http://localhost:16025/api/capture \
-H "Content-Type: application/json" \
-d '{
"url": "https://news.ycombinator.com",
@@ -127,7 +127,7 @@ curl -X POST http://localhost:5000/api/capture \
--output full_page.png
# 自定义视口
curl -X POST http://localhost:5000/api/capture \
curl -X POST http://localhost:16025/api/capture \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
@@ -144,7 +144,7 @@ import requests
# 截图
response = requests.post(
'http://localhost:5000/api/capture',
'http://localhost:16025/api/capture',
json={
'url': 'https://example.com',
'action': 'screenshot'
@@ -155,7 +155,7 @@ with open('screenshot.png', 'wb') as f:
# 提取HTML
response = requests.post(
'http://localhost:5000/api/capture',
'http://localhost:16025/api/capture',
json={
'url': 'https://example.com',
'action': 'html'
@@ -169,7 +169,7 @@ print(html)
```javascript
// 截图
const response = await fetch('http://localhost:5000/api/capture', {
const response = await fetch('http://localhost:16025/api/capture', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
@@ -182,7 +182,7 @@ const response = await fetch('http://localhost:5000/api/capture', {
const blob = await response.blob();
// 提取HTML
const response = await fetch('http://localhost:5000/api/capture', {
const response = await fetch('http://localhost:16025/api/capture', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
@@ -199,7 +199,7 @@ console.log(data.html);
### 使用 Gunicorn
```bash
gunicorn -w 4 -b 0.0.0.0:5000 app:app
gunicorn -w 4 -b 0.0.0.0:16025 app:app
```
### 使用 Systemd 服务
@@ -230,12 +230,12 @@ RUN playwright install chromium --with-deps
COPY . .
EXPOSE 5000
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"]
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:16025", "app:app"]
```
```bash
docker build -t web-capture-api .
docker run -p 5000:5000 web-capture-api
docker run -p 16025:16025 web-capture-api
```
## 性能优化
+1080 -34
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -23,4 +23,4 @@ echo "运行方式:"
echo " 开发模式: python3.12 app.py"
echo " 生产模式: gunicorn -w 4 -b 0.0.0.0:5000 app:app"
echo ""
echo "访问地址: http://localhost:5000"
echo "访问地址: http://localhost:16025"
+2 -2
View File
@@ -6,14 +6,14 @@ services:
image: web-capture-api:latest
container_name: web-capture-api
ports:
- "5000:5000"
- "16025:16025"
environment:
- TZ=Asia/Shanghai
volumes:
- ./captures:/tmp/web_captures
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
test: ["CMD", "curl", "-f", "http://localhost:16025/health"]
interval: 30s
timeout: 10s
retries: 3
+2 -2
View File
@@ -110,7 +110,7 @@ echo " cd $(pwd)"
echo " $PYTHON app.py"
echo ""
echo "📖 访问地址:"
echo " http://localhost:5000"
echo " http://localhost:16025"
echo ""
echo "📚 API 文档:"
echo " http://localhost:5000/api"
echo " http://localhost:16025/api"
+69
View File
@@ -0,0 +1,69 @@
# 手动 Chrome 捕获指南
## 方案三完整流程
### 1️⃣ 启动真实 Chrome(带调试端口)
在您的本地机器或服务器上运行:
```bash
# Linux
google-chrome --remote-debugging-port=9222 https://www.techpowerup.com/gpu-specs/rtx-pro-6000-blackwell.c4272
# 或者使用已有的 Chrome 进程(需要先关闭所有 Chrome)
google-chrome-stable --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
```
### 2️⃣ 手动验证(如 Cloudflare
- 在浏览器中手动完成验证过程
- 等待页面完全加载
- 确认可以看到正常内容
### 3️⃣ 连接到 Chrome 并截图
验证完成后,运行脚本:
```bash
# 连接到 Chrome 并截图
python3.12 /tmp/connect_chrome.py techpowerup
# 或者捕获当前所有页面
python3.12 /tmp/connect_chrome.py
```
### 4️⃣ 查看结果
```bash
# 查看截图
ls -lh /tmp/chrome_capture_*.png
# 查看HTML
head -100 /tmp/chrome_html_0.html
```
## API 集成方案
如果需要通过 API 获取内容,可以:
1. 在服务代码中添加 CDP 连接选项
2. 用户先手动验证
3. API 连接到已验证的浏览器实例
## 注意事项
⚠️ **重要**
- Chrome 必须带 `--remote-debugging-port=9222` 启动
- 所有 Chrome 进程必须先关闭(或使用新的 user-data-dir
- 验证完成后才能运行脚本
- 截图后浏览器保持打开,可以继续使用
## 一键脚本
```bash
# 启动 Chrome 并等待用户验证
google-chrome --remote-debugging-port=9222 "https://www.techpowerup.com/gpu-specs/rtx-pro-6000-blackwell.c4272" &
echo "请在浏览器中完成验证,然后按 Enter 继续截图..."
read
python3.12 /tmp/connect_chrome.py techpowerup
```
+872 -25
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -7,7 +7,7 @@ import requests
import json
import sys
API_URL = "http://localhost:5000"
API_URL = "http://localhost:16025"
def test_health():
+1 -1
View File
@@ -6,7 +6,7 @@ After=network.target
Type=simple
User=openclaw
WorkingDirectory=/home/openclaw/.openclaw/workspace-hz4th_coder/works/web-capture-api
ExecStart=/home/openclaw/.openclaw/workspace-hz4th_coder/works/web-capture-api/venv/bin/gunicorn -w 4 -b 0.0.0.0:5000 app:app
ExecStart=/home/openclaw/.openclaw/workspace-hz4th_coder/works/web-capture-api/venv/bin/gunicorn -w 4 -b 0.0.0.0:16025 app:app
Restart=always
RestartSec=10