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;
14
15pub(crate) mod bridge;
16pub(crate) mod crawl;
17pub(crate) mod error;
18pub(crate) mod fetch;
19pub(crate) mod layout;
20pub(crate) mod map;
21pub(crate) mod net;
22pub(crate) mod pdf;
23pub(crate) mod robots;
24pub(crate) mod runtime;
25pub(crate) mod scope;
26pub(crate) mod screenshot;
27pub(crate) mod sys;
28
29pub use crawl::{CrawlError, CrawlOptions, CrawlPage, CrawlResult, crawl, crawl_each};
30pub use error::{Error, Result};
31pub use fetch::{ConsoleLevel, ConsoleMessage, FetchOptions, Page, extract_json, fetch, markdown, text};
32pub use map::{MapOptions, MappedUrl, map};
33pub use net::{NetworkPolicy, validate_url};
34
35/// Set the network policy. Must be called at most once, before any engine use.
36pub fn init(policy: NetworkPolicy) {
37    bridge::set_engine_policy(policy);
38}