pub struct Scraper { /* private fields */ }Implementations§
Source§impl Scraper
impl Scraper
pub fn new(config: ScraperConfig) -> Result<Self, ScraperError>
Sourcepub async fn probe_engines(&self) -> Vec<EngineProbe>
pub async fn probe_engines(&self) -> Vec<EngineProbe>
把内核链里的每个内核真的启动一次,逐个给出结果(doctor 用):文件在不等于能启动,
启动即崩的兜底内核要说出来。
Sourcepub async fn probe_browsers(&self)
pub async fn probe_browsers(&self)
服务启动时在后台把每个内核启动一次,确认哪些能用(日志里写明),能用的浏览器留着备用。
pub async fn shutdown(&self)
pub async fn scrape( &self, url: &str, opts: &ScrapeOptions, ) -> Result<Document, ApiError>
Sourcepub fn audit_robots_ignored(
&self,
kind: RequestKind,
mode: RobotsMode,
url: &str,
)
pub fn audit_robots_ignored( &self, kind: RequestKind, mode: RobotsMode, url: &str, )
整站爬取或 map 实际忽略了 robots.txt 时写一条审计记录(没配置审计日志时什么都不做)。
pub fn policy(&self) -> &Policy
Sourcepub fn route_pages(&self, runner: Arc<dyn PageRunner>) -> bool
pub fn route_pages(&self, runner: Arc<dyn PageRunner>) -> bool
网关模式:此后爬取里的页面交给 runner 执行(只能设一次,之后的调用返回 false)。
pub fn page_runner(&self) -> Option<&Arc<dyn PageRunner>>
Sourcepub fn planner(&self) -> &RenderPlanner
pub fn planner(&self) -> &RenderPlanner
渲染决策的计数表(多服务器工人上报统计、导入网关下发的先验用)。
pub fn learner(&self) -> &HostLearner
Sourcepub fn engine_count(&self) -> usize
pub fn engine_count(&self) -> usize
内核链的长度(换内核决策的族按内核序号区分)。
pub fn network_stage_snapshots(&self) -> Vec<StageSnapshot>
pub fn transport_phase_snapshots(&self) -> Vec<PhaseSnapshot>
pub fn crawl_slots(&self) -> &AdaptiveConcurrencyGate
Sourcepub fn concurrency(&self) -> usize
pub fn concurrency(&self) -> usize
当前的全局并发目标(限速器的 USL 控制器给出,冷启动等于配置的全局并发)。
多服务器网关上页面由工人执行:取在线工人报告的准入容量之和(至少 1), 爬取的在途上限和名额闸门都跟着它走。单主机没有装执行方,路径不变。
Sourcepub fn observe_crawl(&self, _queue_wait: Duration, _failed: bool)
pub fn observe_crawl(&self, _queue_wait: Duration, _failed: bool)
爬取里一页结束。并发目标由限速器在名额归还时按观测窗更新(事件驱动), 这里只把爬取闸门的上限同步过去;取代 0.81 每秒采样一次的运行时调优器。
Sourcepub async fn scrape_with(
&self,
url: &str,
opts: &ScrapeOptions,
mode: RobotsMode,
) -> Result<Document, ApiError>
pub async fn scrape_with( &self, url: &str, opts: &ScrapeOptions, mode: RobotsMode, ) -> Result<Document, ApiError>
按给定的 robots 模式抓一页;整站爬取和 map 用它,robots 模式由调用方按请求类型决定。
先查缓存(语义同 Firecrawl 的 maxAge、minAge、storeInCache),没命中再抓取并写入。
queryFilter、LLM 格式和 changeTracking 都在缓存之外、基于正文 Markdown 做,
缓存里存的总是完整正文。
Sourcepub async fn scrape_audited(
&self,
kind: &str,
url: &str,
opts: &ScrapeOptions,
mode: RobotsMode,
) -> Result<Document, ApiError>
pub async fn scrape_audited( &self, kind: &str, url: &str, opts: &ScrapeOptions, mode: RobotsMode, ) -> Result<Document, ApiError>
抓一页并写审计记录。kind 区分单页抓取和爬取里的页面。
Trait Implementations§
Source§impl Engine for Scraper
impl Engine for Scraper
Source§fn admitted_concurrency(&self) -> Option<usize>
fn admitted_concurrency(&self) -> Option<usize>
统一准入:批量任务的并发取当前全局在途数目标(限速器的 USL 控制器)。
fn scrape<'a>( &'a self, url: &'a str, opts: &'a ScrapeOptions, ) -> BoxFuture<'a, Result<Document, ApiError>>
Source§fn parse<'a>(
&'a self,
file: Upload,
opts: &'a ScrapeOptions,
) -> BoxFuture<'a, Result<Document, ApiError>>
fn parse<'a>( &'a self, file: Upload, opts: &'a ScrapeOptions, ) -> BoxFuture<'a, Result<Document, ApiError>>
fn map<'a>( &'a self, req: &'a MapRequest, ) -> BoxFuture<'a, Result<Vec<MapLink>, ApiError>>
Source§fn crawl<'a>(
&'a self,
req: &'a CrawlRequest,
sink: Arc<dyn CrawlSink>,
) -> BoxFuture<'a, Result<(), ApiError>>
fn crawl<'a>( &'a self, req: &'a CrawlRequest, sink: Arc<dyn CrawlSink>, ) -> BoxFuture<'a, Result<(), ApiError>>
整站爬取:抓到一页、出错一页、发现新 URL 时都通过
sink 回报,直到爬完或被取消。Source§fn search<'a>(
&'a self,
req: &'a SearchRequest,
) -> BoxFuture<'a, Result<Value, ApiError>>
fn search<'a>( &'a self, req: &'a SearchRequest, ) -> BoxFuture<'a, Result<Value, ApiError>>
/v2/search:返回 Firecrawl 的 data({ "web": [...] })。Source§fn extract<'a>(
&'a self,
req: &'a ExtractRequest,
) -> BoxFuture<'a, Result<Value, ApiError>>
fn extract<'a>( &'a self, req: &'a ExtractRequest, ) -> BoxFuture<'a, Result<Value, ApiError>>
/v2/extract:返回提取出的 JSON。Source§fn supported_formats(&self) -> &'static [&'static str]
fn supported_formats(&self) -> &'static [&'static str]
引擎支持的
formats;请求了不支持的格式时返回 UNSUPPORTED_OPTION,不悄悄忽略。Source§fn supports_actions(&self) -> bool
fn supports_actions(&self) -> bool
是否支持
actions(需要浏览器渲染)。Auto Trait Implementations§
impl !Freeze for Scraper
impl !RefUnwindSafe for Scraper
impl !UnwindSafe for Scraper
impl Send for Scraper
impl Sync for Scraper
impl Unpin for Scraper
impl UnsafeUnpin for Scraper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more