@framers/agentos-ext-web-scraper

中文文档
0.1.5发布于 2026/11/11Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2万

Intelligent web scraping with progressive fallbacks, proxy rotation, and LLM extraction

原始使用文档
文档目录8 节
  1. Installation
  2. Usage
  3. Configuration
  4. Tools
  5. web_scrape
  6. web_scrape_recipe
  7. Notes
  8. License

Web scraper

This pack gives an agent page scraping, structured extraction and named YAML recipe tools. It uses fetch, optional playwright-core browser fallbacks, a regex selector engine and yaml for recipe loading.

Installation

npm install @framers/agentos-ext-web-scraper

Peer dependency: @framers/agentos with range >=0.10.40.

Usage

import { AgentOS } from '@framers/agentos';

const agentos = await AgentOS.create({
  extensionManifest: {
    packs: [
      {
        package: '@framers/agentos-ext-web-scraper',
        options: {
          proxyUrl: process.env.WEB_SCRAPER_PROXY_URL,
          proxyList: process.env.WEB_SCRAPER_PROXY_LIST,
        },
      },
    ],
  },
});

Configuration

OptionSecret idEnvironment variableRequiredDefault
proxyUrlscraper.proxyUrlWEB_SCRAPER_PROXY_URLnoUnset
proxyListscraper.proxyListWEB_SCRAPER_PROXY_LISTnoUnset
minDelayMsNoneNoneno500 ms
maxDelayMsNoneNoneno2000 ms
priorityNoneNoneno50; a falsy value also uses this default
Context loggerNoneNonenoUnset

Proxy settings resolve from truthy options, then context.getSecret, then the environment. proxyList accepts a comma-separated string or an array of strings and takes precedence over proxyUrl. The service rotates through the list; per-request options.proxy overrides it. logger.info receives activation and deactivation messages.

Tools

ToolWhat it does
web_scrapeScrapes a page and returns selector-based data or raw HTML and cleaned text through progressive fallbacks.
web_scrape_recipeRuns a named sequence of scraping steps with parameter and prior-result interpolation.

web_scrape

ParameterTypeRequiredDescription
urlstringyesFully qualified URL to scrape (must start with http:// or https://).
extractobjectnoOptional extraction configuration. Use fields for single-record extraction, or list + listFields for repeating-item extraction.
extract.fieldsobject with string valuesnoMap of output field name to CSS-like selector. Append @attr to extract an attribute value instead of text content.
extract.liststringnoSelector for the repeating container element in a list view.
extract.listFieldsobject with string valuesnoPer-item field selectors, relative to each list container match.
optionsobjectnoOptional per-request scrape settings.
options.tierinteger, minimum 1, maximum 4noStarting scrape tier (1: fetch, 2: Playwright, 3: stealth, 4: LLM fallback).
options.maxTierinteger, minimum 1, maximum 4noHighest tier the service may escalate to (default 4).
options.proxystringnoHTTP/SOCKS5 proxy URL for this request.
options.headersobject with string valuesnoExtra HTTP headers to include.
options.waitForstringnoCSS selector to wait for before extraction (tier two and above only).
options.timeoutinteger, minimum 1000noPer-request timeout in milliseconds (default 30000).
options.javascriptbooleannoSet to true if the page requires JS rendering (skips to tier two).

web_scrape_recipe

ParameterTypeRequiredDescription
recipestringyesName of the recipe to execute (e.g., generic-article, letterboxd-movie).
paramsobject with string valuesyesRuntime parameter values for the recipe. Keys must match the parameter names declared in the recipe definition.

Notes

Both tools declare capability:web_scrape. The service tries plain fetch, headless Playwright, stealth Playwright, then a text-fetch fallback. javascript: true starts at the browser tier unless maxTier caps it lower. A cached successful tier can raise the starting tier. Fetch requests and browser navigation or selector waits default to 30000 ms per operation, rather than a total deadline.

Browser fallbacks dynamically import playwright-core and launch Chromium. If the import or launch fails, the service continues to the next allowed tier. playwright-core is not listed in the package's dependencies. Proxies are passed to Playwright launch options; the fetch paths do not apply them. Each browser attempt closes its browser afterward.

The text fallback rejects content shorter than 200 characters and recognized Cloudflare challenge pages. With extract, it returns text and _llmExtractionRequired: true; the calling runtime performs any LLM extraction. Browser paths also reject recognized challenge pages. Plain fetch accepts successful HTTP responses without this challenge check. Failure across all allowed tiers returns success: false and an error message.

Extraction supports tag, .class, #id, tag.class and a @attr suffix. It uses regex matching rather than a full CSS parser. Unsupported or unmatched field selectors return empty strings. Empty extraction results do not trigger fallback escalation.

Rate limiting uses random delays between minDelayMs and maxDelayMs for repeated requests to a domain. Successful tiers are cached per domain for 30 minutes, with a maximum of 500 entries.

Activation loads YAML recipes from the package's recipes/ directory, then ~/.wunderland/scraper-recipes/; user recipes override matching names. The bundled recipe names are generic-article and letterboxd-movie. The engine looks up loaded names and does not load a path supplied as recipe. Missing recipes return an error. Invalid recipe files produce console warnings and are skipped.

Recipe steps run sequentially and interpolate {{paramName}}, {{steps.stepName.data.field}} and {{steps.stepName.items[N].field}} in URLs and selectors. Parameters prefixed with = in a recipe have defaults; missing values otherwise become empty strings. Interpolation does not URL-encode values. Failed steps stop execution and return partial data. A step's options.maxItems caps list results. The bundled Letterboxd recipe uses descendant selectors that the regex extraction engine does not implement.

License

Apache-2.0

版本与发布记录

@framers/agentos-ext-web-scraper 共发布 6 个版本,首次发布于 2026/05/02;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.5latest2026/11/114 天前
0.1.42026/10/2125 天前
0.1.32026/10/121 个月前
0.1.22026/10/111 个月前
0.1.12026/10/081 个月前
0.1.02026/05/026 个月前

关于 @framers/agentos-ext-web-scraper 的常见问题

@framers/agentos-ext-web-scraper 是什么?

Intelligent web scraping with progressive fallbacks, proxy rotation, and LLM extraction

如何安装 @framers/agentos-ext-web-scraper?

在项目目录运行 npm install @framers/agentos-ext-web-scraper,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@framers/agentos(>=0.10.40)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@framers/agentos-ext-web-scraper 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@framers/agentos-ext-web-scraper 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@framers/agentos-ext-web-scraper 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@framers/agentos-ext-web-scraper 可以商用吗?

@framers/agentos-ext-web-scraper 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@framers/agentos-ext-web-scraper 的下载量有多少?

根据 npm 官方下载统计,@framers/agentos-ext-web-scraper 在 2026/10/16 – 2026/11/14 这 30 天内被下载 20,224 次,日均约 674 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@framers/agentos-ext-web-scraper 还在维护吗?

最新版本 0.1.5 发布于 2026/11/11(4 天前);至今共发布 6 个版本,其中过去 12 个月发布了 6 个;首次发布于 2026/05/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。