Browser Session Archive
Extracts and archives chatgpt.com and claude.ai share links to Markdown using Chrome DevTools Protocol.
Triggers
User message contains:
- 1. Keywords:
提取 chatgpt, 提取 claude, 提取文档, 提取 chatgpt 对话, 提取 claude 对话, 归档 chatgpt 对话, 归档 claude 对话, 保存 chatgpt 对话, 保存 claude 对话, extract chatgpt, extract claude, archive chatgpt, archive claude, save chatgpt, INLINECODE14 - Links:
-
https://chatgpt.com/share/{share-id}
- INLINECODE16
Usage
Quick Start
CODEBLOCK0
Step by Step
CODEBLOCK1
Environment Variables
| Variable | Description | Default |
|---|
| INLINECODE17 | Chrome debugging port | INLINECODE18 |
| INLINECODE19 |
Share link URL | (required) |
|
OUTPUT_DIR | Output directory |
~/LookBack/{date}/{ChatGPT\|Claude} |
Output Structure
CODEBLOCK2
Prerequisites
- 1. Chrome Debug Mode: Start Chrome with INLINECODE22
CODEBLOCK3
- 2. Install Dependencies:
CODEBLOCK4
Error Handling
| Error | Cause | Solution |
|---|
| Connection refused | Chrome debug port not open | Start Chrome with INLINECODE23 |
| Timeout |
Page loading slow | Increase wait time or refresh manually |
| Target not found | Invalid link | Verify the share link is correct |
Scripts
| Script | Description |
|---|
| INLINECODE24 | CDP capture script, extracts HTML |
| INLINECODE25 |
HTML to Markdown converter |
|
extract.sh | One-click entry script |
References
浏览器会话归档
使用Chrome DevTools协议提取chatgpt.com和claude.ai的分享链接并归档为Markdown格式。
触发条件
用户消息包含:
- 1. 关键词:提取 chatgpt、提取 claude、提取文档、提取 chatgpt 对话、提取 claude 对话、归档 chatgpt 对话、归档 claude 对话、保存 chatgpt 对话、保存 claude 对话、extract chatgpt、extract claude、archive chatgpt、archive claude、save chatgpt、save claude
- 链接:
- https://chatgpt.com/share/{分享ID}
- https://claude.ai/share/{分享ID}
使用方法
快速开始
bash
复制脚本到PATH路径
cp {baseDir}/scripts/extract.sh /usr/local/bin/
chmod +x /usr/local/bin/extract.sh
运行
extract.sh https://chatgpt.com/share/xxx
extract.sh https://claude.ai/share/xxx
分步操作
bash
1. 捕获HTML
cd {baseDir}/scripts
CHROME
DEBUGPORT=9222 TARGET_URL=https://chatgpt.com/share/xxx \
node capture-cdp.js
2. 转换为Markdown(使用步骤1的输出路径)
node convert-markdown.js --metadata ~/LookBack/$(date +%Y-%m-%d)/ChatGPT/.metadata.json
环境变量
| 变量 | 描述 | 默认值 |
|---|
| CHROMEDEBUGPORT | Chrome调试端口 | 9222 |
| TARGET_URL |
分享链接URL | (必填) |
| OUTPUT_DIR | 输出目录 | ~/LookBack/{日期}/{ChatGPT\|Claude} |
输出结构
~/LookBack/{YYYY-MM-DD}/
├── ChatGPT/
│ ├── {标题}-{时间戳}.md # Markdown文件
│ ├── {标题}-{时间戳}-captured.html # HTML快照
│ └── .metadata.json # 元数据
└── Claude/
└── ...
前置条件
- 1. Chrome调试模式:使用--remote-debugging-port=9222启动Chrome
bash
# macOS
open -a Google Chrome --args --remote-debugging-port=9222
# Linux
google-chrome --remote-debugging-port=9222
- 2. 安装依赖:
bash
npm install -g ws
错误处理
| 错误 | 原因 | 解决方案 |
|---|
| 连接被拒绝 | Chrome调试端口未开启 | 使用--remote-debugging-port启动Chrome |
| 超时 |
页面加载缓慢 | 增加等待时间或手动刷新 |
| 未找到目标 | 无效链接 | 验证分享链接是否正确 |
脚本
| 脚本 | 描述 |
|---|
| capture-cdp.js | CDP捕获脚本,提取HTML |
| convert-markdown.js |
HTML转Markdown转换器 |
| extract.sh | 一键入口脚本 |
参考