npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-web-fetch

v1.0.0

Published

DSH skill + CLI: fetch web pages with a real local browser (Edge/Chrome/Chromium via playwright-core) to pass WAF / anti-bot / JS-rendered pages. Auto system-proxy detection, cookie persistence, HTML/text/Markdown/screenshot/PDF output.

Readme

dsh-web-fetch

用本机真实浏览器抓网页的 DSH 技能 + CLI:绕过 WAF / 人机验证 / JS 渲染,输出 HTML / 纯文本 / Markdown / 截图 / PDF。

npm license

为什么

很多站点(MathWorks、Cloudflare、Incapsula、Datadome……)对普通 HTTP 客户端只返回 "Verifying browser environment / Just a moment" 或 403;页面正文也常由 JS 渲染。 fetch/curl 在这些场景下拿不到内容。本工具用 playwright-core 驱动本机已装的 Edge / Chrome / Chromium,拿到与肉眼一致的渲染结果,并顺手做代理、Cookie、格式转换。

安装

# 作为 CLI / 库使用
npm install -g dsh-web-fetch        # 之后可直接用 webget 命令
# 或在项目里
npm install dsh-web-fetch

# 作为 DSH 技能安装(装完重启 DSH 生效)
git clone https://github.com/Alice-Marx/dsh-web-fetch.git
cd dsh-web-fetch && npm install
powershell -File scripts\install.ps1        # 复制到 ~/.dsh/skills/dsh-web-fetch

依赖:Node.js ≥ 18 + 本机装有 Edge / Chrome / Chromium 之一(无需下载浏览器)。 playwright-core 随包自动安装。

使用

# 整页转 Markdown(保留表格/链接/列表)
webget https://ww2.mathworks.cn/products/agentic-ai.html --markdown

# 纯文本 + 截断(省上下文)
webget https://example.com --text --max-chars 20000

# 只要局部内容
webget https://example.com/docs --selector "main" --markdown --out docs.md

# 截图 + PDF
webget https://example.com --screenshot shot.png --pdf page.pdf

# 批量抓取,输出到目录
webget https://a.com https://b.com --markdown --out out/

# 代理(缺省自动探测系统代理,Windows 读注册表,类 Unix 读环境变量)
webget https://example.com --proxy http://127.0.0.1:7897 --markdown
webget https://example.com --no-proxy --text

# 过验证码 / 登录态:弹出窗口人工操作,Cookie 存下来复用
webget https://example.com --headed --state cookies.json
webget https://example.com/page2 --state cookies.json --markdown

全部参数

| 参数 | 说明 | |---|---| | -t, --text / -m, --markdown / --format html\|text\|markdown | 输出格式(默认 html,渲染后的完整 HTML) | | -o, --out <file\|dir> | 输出文件或目录(多 URL 时传目录) | | --selector <css> | 只抓匹配该选择器的元素 | | --wait-for <css> | 等待该元素出现后再抓取 | | --wait <mode> | domcontentloaded / load / networkidle(默认) | | --settle <ms> | 加载后额外等待,默认 1500 | | --timeout <ms> | 单次导航超时,默认 60000 | | --retries <n> | 遇验证页重试次数,默认 3 | | --scroll | 抓取前滚动页面触发懒加载 | | --max-chars <n> | 截断正文长度 | | --screenshot [file] / --pdf [file] | 保存截图 / PDF | | --links | 额外导出链接清单 <base>.links.json | | --state <file> | 复用 / 保存 Cookie(storageState) | | --headed | 显示浏览器窗口 | | --browser <name> | edge / chrome / chromium / brave / auto | | --proxy <url> / --no-proxy | 指定代理 / 禁用代理 | | --ua <str> / --lang <code> / --viewport <WxH> | UA / 语言 / 视口 | | --json | 以 JSON 输出运行摘要 | | -q, --quiet | 减少日志 | | -V, --version / -h, --help | 版本 / 帮助 |

环境变量

| 变量 | 作用 | |---|---| | WEBGET_BROWSER_PATH | 直接指定浏览器可执行文件路径 | | HTTP_PROXY / HTTPS_PROXY / ALL_PROXY | 代理(优先于系统代理探测) |

作为 Node 库

const { extractInPage } = require('dsh-web-fetch/scripts/lib/extract');
// extractInPage 是可在 Playwright page.evaluate 中运行的页面内容提取函数:
// { title, url, description, canonical, markdown, text, links }

反爬处理策略

  1. 代理自动探测:--proxy > 环境变量 > Windows 注册表系统代理(Clash 等)。
  2. 挑战检测与重试:内置验证页特征库(Cloudflare / Incapsula / Datadome / 中文验证页等), 命中后自动 reload 并逐次延长等待。
  3. Cookie 持久化:--state 保存 Playwright storageState,二次访问免验证。
  4. 指纹缓解:默认 UA 带 Edg 版本号、禁用 AutomationControlled、隐藏 navigator.webdriver。
  5. 人工兜底:--headed 弹窗,用户手动过验证码后 Cookie 自动留存。

目录结构

dsh-web-fetch/
├── SKILL.md               # DSH 技能入口(frontmatter name/description + 使用说明)
├── scripts/
│   ├── webget.js          # CLI 主程序
│   ├── postinstall.js     # 安装自检(浏览器/依赖探测)
│   └── lib/extract.js     # 页面内 Markdown/文本/链接提取(注入浏览器执行)
├── references/
│   ├── webget.md          # 详细用法参考
│   └── troubleshooting.md # 故障速查
└── install.ps1            # 安装为 DSH 技能

许可

MIT