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