SkillsGrove
SkillsGrove/ドキュメント作成/TIGERwu0118/wos-export/wos-export

wos-export

インストール

$npx skills add https://github.com/TIGERwu0118/wos-export --skill wos-export
$git clone --depth 1 https://github.com/TIGERwu0118/wos-export.git /tmp/wos-export && mkdir -p ~/.claude/skills && cp -r /tmp/wos-export/. ~/.claude/skills/wos-export
この Agent Skill をインストールしてください:https://github.com/TIGERwu0118/wos-export/tree/05985b626f77bc451432774f7f5591ecac2a6534/ — まず SKILL.md とスクリプトを読み、安全であることを確認してから、私のスキルフォルダにインストールしてください。

概要

原文の説明 · MIT从 Web of Science (WoS) 批量导出搜索结果记录为 Excel 文件。使用 CloakBrowser 隐身浏览器绕过反自动化检测,支持 Cookie 持久化、分批导出(每批最多 1000 条)和 Full Record 全字段导出。
以下の SKILL.md は TIGERwu0118/wos-export(コミット 05985b6)から MIT ライセンスに基づいて転載しています。本文は変更しておらず、ファイル先頭のメタデータのみ省略し、画像はリンクとして表示し、非常に長いファイルは途中までの表示としています。Copyright 2026。ライセンス:LICENSE。表示しているのは指示ファイルのみです。スクリプト等は元のリポジトリをご覧ください。

WoS Export Skill

通过 CloakBrowser 隐身 Chromium 浏览器,自动从 Web of Science 批量导出搜索结果为 Excel(Full Record)。

适用场景

  • 需要从 WoS 搜索结果页批量导出大量记录(>1000 条)
  • WoS 手动导出操作繁琐,需要自动化
  • 需要绕过 WoS 的反自动化检测(CAPTCHA 等)

不适用场景

  • 仅需导出少量记录(<1000 条,可手动完成)
  • 没有可用的 SOCKS5 代理
  • 没有有效的 WoS 搜索结果页 URL

前置条件

  1. CloakBrowser:隐身 Chromium 浏览器,自动绕过反自动化检测

    pip install cloakbrowser
    

    首次运行会自动下载 Chromium 二进制文件。如果网络受限,可设置代理:

    # Windows (PowerShell)
    $env:HTTPS_PROXY = "socks5h://127.0.0.1:7890"
    python -c "import cloakbrowser; cloakbrowser.ensure_binary()"
    
  2. Python 依赖:

    pip install pandas xlrd openpyxl
    
  3. 本地代理:需要 SOCKS5 代理(默认 socks5://127.0.0.1:7890)用于访问 WoS

  4. WoS 搜索结果 URL:从 Clarivate China (webofscience.clarivate.cn) 获取的搜索结果页 URL

核心技术要点

1. 所有交互通过 page.evaluate() JS DOM 操作

WoS 页面有 OneTrust cookie 叠加层,会拦截 Playwright 定位器的指针事件。所有点击操作必须通过 JavaScript DOM 操作完成。

2. Cookie 持久化

首次运行时接受 OneTrust cookie 并保存,后续运行自动加载,避免重复操作。

3. WoS 每批最多导出 1000 条

这是 WoS 的硬性限制。脚本自动分批处理。

4. 下载捕获

使用 page.expect_download() 捕获 XLS 下载事件,直接保存到指定目录。

快速开始

# 导出 20000 条搜索结果,每批 1000 条
python scripts/wos_batch_export.py \
  --url "https://webofscience.clarivate.cn/wos/woscc/summary/..." \
  --total 20000

# 跳过已下载的批次(断点续传)
python scripts/wos_batch_export.py \
  --url "https://..." \
  --total 20000 \
  --skip-existing

# 仅合并已下载的 XLS 文件
python scripts/wos_batch_export.py --merge-only --url dummy --total 1

导出流程

启动 CloakBrowser(headless=True, proxy="socks5://127.0.0.1:7890")
  → 加载已保存的 Cookie(如有)
  → 导航到 WoS 搜索结果 URL
  → 接受 OneTrust Cookie: JS click #onetrust-accept-btn-handler
  → 保存 Cookie
  → 循环每批:
    → JS click #export-trigger-btn(打开导出菜单)
    → JS click "Excel"(选择 Excel 格式)
    → JS click #radio3-input(选择"Records from:"范围)
    → JS fill input[name='markFrom'] 和 input[name='markTo']
    → JS click Full Record 下拉选择
    → JS click #exportButton → 捕获下载事件
    → 保存为 {start}-{end}.xls
  → 合并所有 XLS 为 merged_wos_full_record.xlsx

JS 点击模式参考

所有 WoS 交互必须使用 page.evaluate() 进行 DOM 操作,不要使用 Playwright 定位器。

# 接受 Cookie
page.evaluate("() => document.getElementById('onetrust-accept-btn-handler').click()")

# 打开导出菜单
page.evaluate("() => document.getElementById('export-trigger-btn').click()")

# 点击 Excel 菜单项(文本匹配)
page.evaluate("""() => {
    const items = document.querySelectorAll('*');
    for (const el of items) {
        if (el.innerText && el.innerText.trim() === 'Excel'
            && el.offsetParent !== null && el.children.length === 0) {
            el.click(); return;
        }
    }
}""")

# 选择 "Records from:" 单选按钮
page.evaluate("() => document.getElementById('radio3-input').click()")

# 填充范围(使用 execCommand 兼容 Angular 响应式表单)
page.evaluate("""(from_val, to_val) => {
    const from = document.querySelector("input[name='markFrom']");
    const to = document.querySelector("input[name='markTo']");
    if (from) { from.focus(); from.value = ''; document.execCommand('insertText', false, from_val); }
    if (to) { to.focus(); to.value = ''; document.execCommand('insertText', false, to_val); }
}""", str(start), str(end))

# 选择 Full Record
page.evaluate("() => document.querySelector(\"button[aria-label*='Filter by']\")?.click()")
page.evaluate("""() => {
    const items = document.querySelectorAll('span, mat-option, [role="option"]');
    for (const item of items) {
        if (item.innerText.trim() === 'Full Record') { item.click(); return; }
    }
}""")

# 最终导出
page.evaluate("() => document.getElementById('exportButton').click()")

命令行参数

参数 说明 默认值
--url WoS 搜索结果页 URL 必填
--total 总记录数 必填
--batch-size 每批记录数 1000
--start 起始记录编号 1
--skip-existing 跳过已下载的批次 否
--merge-only 仅合并已有 XLS 文件 否

输出文件结构

wos-export/
├── SKILL.md                  # 本文件
├── scripts/
│   └── wos_batch_export.py   # 批量导出脚本
├── README.md                 # GitHub 说明
├── requirements.txt          # Python 依赖
└── example_output/
    ├── cookies.json          # 保存的 WoS Cookie(示例)
    └── downloads/
        ├── 1-1000.xls
        ├── 1001-2000.xls
        ├── ...
        └── merged_wos_full_record.xlsx

注意事项

  1. 代理必须可用:CloakBrowser 启动时需要 SOCKS5 代理,确保代理正在运行
  2. WoS URL 有效期:搜索结果 URL 会过期,获取后尽快使用
  3. 下载超时:如果某批下载超时,脚本会标记为 FAIL 并继续下一批。使用 --skip-existing 可以重跑失败批次
  4. 合并需要 xlrd:WoS 导出的 XLS 是真正的 Excel 二进制格式(不是 HTML),合并需要 xlrd 库
  5. CloakBrowser 版本:建议 >= 0.3.30,旧版本可能缺少 Chromium 二进制文件

常见问题

Q: 为什么不能用 Playwright 定位器? A: WoS 页面有 OneTrust cookie 同意弹窗,这个叠加层会拦截所有指针事件。只有 JS DOM 操作能绕过它。

Q: 为什么 execCommand('insertText') 而不是直接赋值? A: WoS 使用 Angular 框架的响应式表单,直接赋值 input.value 不会触发 Angular 的变更检测。execCommand('insertText') 模拟用户输入,能正确触发框架更新。

Q: 导出超时怎么办? A: 默认每批 120 秒超时。如果超时,脚本会继续下一批。完成后用 --skip-existing 重跑失败的批次。

ライセンス全文を見る(MIT)
MIT License

Copyright (c) 2026

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.