mcpField
W
wos-download

wos-download

github.com/cookjohn生产力13092 次安装33 周前更新
代码仓库

关于 wos-download

wos-download 是从 Web of Science 论文记录尝试获取 PDF 全文的浏览器操作技能,适用于需要下载论文的研究人员。它会跟随出版商链接并判断下载、登录要求或付费墙等结果;访问权限取决于机构订阅。

主要功能

  1. 01从 Web of Science 记录提取全文链接
  2. 02跳转至出版商页面
  3. 03检测 PDF、登录要求及付费墙
  4. 04按约定格式命名下载文件

适用场景

  1. 01尝试下载 Web of Science 论文全文
  2. 02通过机构访问权限获取出版商 PDF
  3. 03判断论文无法下载的原因

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/cookjohn/wos-skills --skill wos-download

安装后在 Claude Code 中输入/wos-download确认已加载。

详细介绍

WoS 下载

从 Web of Science 下载论文的 PDF 全文。

重要限制

  • PDF 访问权限取决于机构订阅。即使是开放获取论文,也可能需要在出版商网站上进行身份验证。
  • 跨源下载:a.download 技巧仅适用于浏览器当前位于显示 PDF 的同源页面时。对于跨源重定向(例如 WoS → Wiley),此方法不起作用。
  • 出版商登录墙:在没有机构代理的情况下访问时,即使是开放获取论文,Wiley、Elsevier、Springer 等也可能重定向到登录页面。

步骤

步骤 1:导航到完整记录

如果当前不在完整记录页面:

navigate_page({
  url: "{BASE_URL}/wos/woscc/full-record/{WOS_ID}",
  initScript: "Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"
})
步骤 2:查找全文链接
async () => {
  for (let i = 0; i < 20; i++) {
    if (document.querySelector('[data-ta="FullRTa-fullRecordtitle-0"]')) break;
    await new Promise(r => setTimeout(r, 500));
  }
  await new Promise(r => setTimeout(r, 1000));

  const title = document.querySelector('[data-ta="FullRTa-fullRecordtitle-0"]')?.textContent?.trim() || '';

  const links = [...document.querySelectorAll('a[data-ta^="FRLinkTa"]')].map(a => ({
    text: a.textContent?.trim()?.replace(/open_in_new/g, '').trim(),
    href: a.href,
    dataTa: a.getAttribute('data-ta')
  }));

  const doiEl = document.querySelector('a[href*="doi.org"]');
  const doi = doiEl?.href || '';

  return { title, links, doi };
}
步骤 3:打开全文链接

导航到出版商链接:

navigate_page({
  url: "{CHOSEN_LINK}",
  initScript: "Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"
})
步骤 4:检查 PDF 状态并尝试下载
async () => {
  await new Promise(r => setTimeout(r, 5000));

  const url = window.location.href;
  const contentType = document.contentType;

  // Direct PDF — trigger download immediately
  if (contentType === 'application/pdf') {
    const a = document.createElement('a');
    a.href = url;
    a.download = '{FILENAME}';
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    return { status: 'downloaded', url };
  }

  // Publisher HTML page — look for PDF links
  const pdfLinks = [...document.querySelectorAll('a')].filter(a => {
    const href = a.href || '';
    const text = a.textContent || '';
    return href.includes('/pdf/') || href.includes('.pdf') ||
           text.toLowerCase().includes('download pdf') || text.toLowerCase() === 'pdf';
  }).map(a => ({
    text: a.textContent?.trim()?.substring(0, 50),
    href: a.href?.substring(0, 120)
  }));

  // Check for access denial
  const bodyText = document.body.innerText?.substring(0, 1000) || '';
  const loginRequired = bodyText.includes('Sign in') || bodyText.includes('Log in') ||
                         bodyText.includes('Individual login') || bodyText.includes('Institutional login');
  const paywall = bodyText.includes('Purchase') || bodyText.includes('Subscribe') ||
                  bodyText.includes('Access Denied');

  return {
    status: loginRequired ? 'login_required' : paywall ? 'paywall' : pdfLinks.length > 0 ? 'pdf_links_found' : 'publisher_page',
    url: url.substring(0, 100),
    pdfLinks: pdfLinks.slice(0, 5),
    pageTitle: document.title
  };
}
步骤 5:处理结果
状态操作
downloaded报告成功,文件已保存到默认下载文件夹
pdf_links_found点击出版商页面上的“Download PDF”链接
login_required告知用户:“出版商要求登录。请尝试通过机构 VPN/WebVPN 访问,或手动下载。”
paywall告知用户:“这篇论文需要订阅才能访问。”
publisher_page告知用户:“当前位于出版商页面,但未找到直接 PDF 链接。”
点击出版商的 Download PDF 按钮

如果状态为 pdf_links_found,使用 take_snapshot 查找 Download PDF 按钮,然后使用 click 点击:

1. take_snapshot → find "Download PDF" link uid
2. click(uid)
3. evaluate_script → wait 5s, check if PDF loaded (contentType === 'application/pdf')
4. If PDF loaded → trigger download with a.download

文件名约定

{FirstAuthor}_{Year}_{ShortTitle}.pdf

示例:Johnson_2025_Citizen-Centric_AI_Government.pdf

已知问题

  • WoS 网关链接(/api/gateway?...DestURL=...)会通过 GetFTR 重定向到出版商。最终访问页面取决于机构的访问权限。
  • Wiley:没有机构 Cookie 时,即使是开放获取论文,也会显示登录页面。ePDF 阅读器(/doi/epdf/...)是基于 iframe 的阅读器,无法下载 PDF。
  • Elsevier/ScienceDirect:如果机构拥有访问权限,可能会直接提供 PDF;否则会显示摘要页面。
  • 尝试下载后 SID 丢失:导航到外部出版商网站会清除 WoS 性能条目。返回 WoS 时,请使用基于 URL 的搜索,或先导航到任意 WoS 页面以重新建立 SID。

注意事项

  • 此技能需要调用工具 3–4 次:导航到记录 + 提取链接 + 导航到出版商页面 + 下载
  • PDF 访问权限取决于机构订阅
  • 每次导航都要使用 initScript
  • 如果下载失败,建议用户尝试通过机构 VPN 访问,或使用浏览器手动下载

评论

支持 Markdown