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)
- 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两种任务都能查。 - 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§
Enums§
- Scraper
Error - 创建
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 解析本身处理。 - text_
weight - 正文的加权长度:空白不算,中日韩文字按 [
CJK_WEIGHT] 算。