Skip to main content

Engine

Trait Engine 

Source
pub trait Engine:
    Send
    + Sync
    + 'static {
    // Required method
    fn scrape<'a>(
        &'a self,
        url: &'a str,
        opts: &'a ScrapeOptions,
    ) -> BoxFuture<'a, Result<Document, ApiError>>;

    // Provided methods
    fn map<'a>(
        &'a self,
        _req: &'a MapRequest,
    ) -> BoxFuture<'a, Result<Vec<MapLink>, ApiError>> { ... }
    fn crawl<'a>(
        &'a self,
        _req: &'a CrawlRequest,
        _sink: Arc<dyn CrawlSink>,
    ) -> BoxFuture<'a, Result<(), ApiError>> { ... }
    fn search<'a>(
        &'a self,
        _req: &'a SearchRequest,
    ) -> BoxFuture<'a, Result<Value, ApiError>> { ... }
    fn extract<'a>(
        &'a self,
        _req: &'a ExtractRequest,
    ) -> BoxFuture<'a, Result<Value, ApiError>> { ... }
    fn supported_formats(&self) -> &'static [&'static str] { ... }
    fn supports_actions(&self) -> bool { ... }
}

Required Methods§

Source

fn scrape<'a>( &'a self, url: &'a str, opts: &'a ScrapeOptions, ) -> BoxFuture<'a, Result<Document, ApiError>>

Provided Methods§

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(需要浏览器渲染)。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§