Skip to main content

Crate pagesift

Crate pagesift 

Source
Expand description

pagesift:把网页变成给大模型用的干净 Markdown。

这个 crate 既是库也是命令行工具。库的入口是 Scraper:

let scraper = pagesift::Scraper::new(pagesift::ScraperConfig::default())?;
let doc = scraper.scrape("https://example.com", &Default::default()).await?;
println!("{}", doc.markdown.unwrap_or_default());

Re-exports§

pub use pagesift_api as api;

Modules§

adaptive
动态自适应性能调优模块 (Adaptive Resource & Concurrency Tuning Engine)
audit
审计日志:每次抓取写一行 JSON(只有元数据),结果可疑时另存当时的 HTML,供事后复现。
collect
Incremental JSON API collection with page checkpoints and acknowledged events. A source must have one writer and a stable, authoritative listing to enable deletion. Delivery is at least once; destinations must deduplicate events.
config
配置(PRD 6.11):pagesift.toml,路径由 --config 或 PAGESIFT_CONFIG 指定。 优先级:命令行参数 > 环境变量 > 配置文件 > 默认值。
download
Identity-addressed, bounded, resumable file archive. This is a downloader, not a site-extractor library. One advisory lock protects each archive root.
mcp
MCP 工具:把 pagesift-mcp 定义的 5 个工具接到真正的抓取引擎上。 crawl 和 batch scrape 复用 API 层的任务管理,pagesift_crawl_status 两种任务都能查。 配置了审计日志时多一个 pagesift_report_issue,让调用方把看到的错误结果记下来。
media
Explicit media protocol adapters. An adapter is selected by the caller; unknown sites never silently fall back to scraping arbitrary JSON URLs.
postprocess
Deterministic filenames and recoverable binary + metadata publication. The sidecar is the commit marker, published last; this is not a two-file atomic FS.
scripts
Opt-in, origin-scoped external module traversal. Candidates carry provenance and remain separate from observed browser traffic or confirmed GET requests.
session
Explicit on-disk ownership for an HTTP session. Persistence is opt-in and the caller saves after requests; no hidden shared cookie file or automatic identity swap.
stream
Native bounded HLS/DASH VOD planning. Unsupported live/encrypted/index-based formats fail explicitly. Planning does not execute a player or a helper tool.

Structs§

Scraper
ScraperConfig

Enums§

ScraperError
创建 Scraper 失败:网络层或 LLM 客户端的配置不对。

Constants§

AUTO_RENDER_ARTICLE_MIN_CHARS
已经认出是一篇文章(有发布时间或 og:type=article)时,正文到这么多加权字符就不再渲染: 短新闻 HTTP 已经拿全了。AiSeek 的生产数据里,63% 的渲染拿到的文字和 HTTP 一样多, 多半就是这类短文章。
AUTO_RENDER_MIN_CHARS
F-1.9:HTTP 抓到的正文少于这么多(加权)字符时,engine: auto 升级到浏览器渲染。 中日韩文字一个字按 [CJK_WEIGHT] 个字符算(信息量和几个拉丁字母相当),见 text_weight。

Functions§

needs_render
engine: auto 时 HTTP 的结果是否还要用浏览器渲染。
normalize_url
URL 规范化(F-6.2),用来去重:去掉 fragment;查询参数排序,或者整个去掉。 协议和主机的小写、默认端口、.. 路径由 URL 解析本身处理。
office_markdown
把一份 Office/EPUB/CSV 文档转成 Markdown,供引擎和评测共用。deadline 到了报超时。
set_cpu_capacity
进程可用的 CPU 数,由建运行时的一方在绑核之前设置。
text_weight
正文的加权长度:空白不算,中日韩文字按 [CJK_WEIGHT] 算。