Skip to main content

Scraper

Struct Scraper 

Source
pub struct Scraper { /* private fields */ }

Implementations§

Source§

impl Scraper

Source

pub async fn map(&self, req: &MapRequest) -> Result<Vec<MapLink>, ApiError>

Source

pub async fn crawl( &self, req: &CrawlRequest, sink: Arc<dyn CrawlSink>, ) -> Result<(), ApiError>

整站爬取。深度按发现顺序计算:起始页和 sitemap 里的页面是 0。 带 query 时按相关性优先调度(见 [crate::focus]),否则广度优先。

Source§

impl Scraper

Source

pub async fn search(&self, req: &SearchRequest) -> Result<Value, ApiError>

Source

pub async fn extract(&self, req: &ExtractRequest) -> Result<Value, ApiError>

Source§

impl Scraper

Source

pub async fn parse( &self, upload: Upload, opts: &ScrapeOptions, ) -> Result<Document, ApiError>

解析上传的文件并写审计记录(kind: parse)。不存快照:上传的文件往往不公开。

Source§

impl Scraper

Source

pub fn new(config: ScraperConfig) -> Result<Self, ScraperError>

Source

pub async fn probe_browsers(&self)

服务启动时在后台把每个内核启动一次,确认哪些能用(日志里写明),能用的浏览器留着备用。

Source

pub async fn shutdown(&self)

Source

pub async fn scrape( &self, url: &str, opts: &ScrapeOptions, ) -> Result<Document, ApiError>

Source

pub fn audit(&self) -> Option<&Arc<Audit>>

审计日志(没配置时为 None)。

Source

pub fn network_stage_snapshots(&self) -> Vec<StageSnapshot>

Source

pub fn transport_phase_snapshots(&self) -> Vec<PhaseSnapshot>

Source

pub fn concurrency(&self) -> usize

Returns current active concurrency limit.

Source

pub fn set_concurrency(&self, target: usize)

Dynamically adjusts the global crawl concurrency limit at runtime.

Trait Implementations§

Source§

impl Engine for Scraper

Source§

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>>

/v2/parse:解析调用方上传的文件(PDF、HTML),返回和 scrape 相同的文档。 opts 已经过 crate::check_parse_options 校验。
Source§

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>>

整站爬取:抓到一页、出错一页、发现新 URL 时都通过 sink 回报,直到爬完或被取消。
Source§

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>>

/v2/extract:返回提取出的 JSON。
Source§

fn supported_formats(&self) -> &'static [&'static str]

引擎支持的 formats;请求了不支持的格式时返回 UNSUPPORTED_OPTION,不悄悄忽略。
Source§

fn supports_actions(&self) -> bool

是否支持 actions(需要浏览器渲染)。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more