Skip to main content

servo_fetch/
lib.rs

1//! Fetch, render, and extract web content as Markdown, JSON, or screenshots with an embedded Servo browser engine.
2//! No Chromium, no containers, no external processes.
3//!
4//! ```no_run
5//! let md = servo_fetch::markdown("https://example.com")?;
6//! # Ok::<(), servo_fetch::Error>(())
7//! ```
8
9#![deny(unsafe_code)]
10
11pub mod extract;
12pub mod sanitize;
13pub mod schema;
14pub mod visibility;
15
16pub(crate) mod bridge;
17pub(crate) mod crawl;
18pub(crate) mod error;
19pub(crate) mod fetch;
20pub(crate) mod layout;
21pub(crate) mod map;
22pub(crate) mod net;
23pub(crate) mod pdf;
24pub(crate) mod robots;
25pub(crate) mod runtime;
26pub(crate) mod scope;
27pub(crate) mod screenshot;
28pub(crate) mod sys;
29
30pub use crawl::{CrawlOptions, CrawlPage, CrawlResult, crawl, crawl_each};
31pub use error::{Error, Result};
32pub use fetch::{ConsoleLevel, ConsoleMessage, FetchOptions, Page, extract_json, fetch, markdown, text};
33pub use map::{MapOptions, MappedUrl, map};
34pub use net::{NetworkPolicy, validate_url};
35pub use visibility::{VisibilityFlags, VisibilityPolicy};
36
37/// Set the network policy. Must be called at most once, before any engine use.
38pub fn init(policy: NetworkPolicy) {
39    bridge::set_engine_policy(policy);
40}