rquest_util/lib.rs
1//! # rquest-util
2//!
3//! [](https://github.com/0x676e67/rquest-util/actions/workflows/ci.yml)
4//! [](./LICENSE)
5//! [](https://crates.io/crates/rquest-util)
6//! [](https://docs.rs/rquest-util)
7//! 
8//!
9//! A collection of utilities to do common things with [rquest](https://github.com/0x676e67/rquest).
10//!
11//! ## Emulation
12//!
13//! - **Emulation Device**
14//!
15//! In fact, most device models have the same `TLS`/`HTTP2` configuration, except that the `User-Agent` is changed.
16//!
17//! ### Default device emulation types
18//!
19//! | **Browser** | **Versions** |
20//! |---------------|--------------------------------------------------------------------------------------------------|
21//! | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135` |
22//! | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134` |
23//! | **Safari** | `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos16_5`, `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari18`, `SafariIPad18`, `Safari18_2`, `Safari18_1_1`, `Safari18_3`, `Safari18_3_1` |
24//! | **OkHttp** | `OkHttp3_9`, `OkHttp3_11`, `OkHttp3_13`, `OkHttp3_14`, `OkHttp4_9`, `OkHttp4_10`, `OkHttp4_12`, `OkHttp5` |
25//! | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`|
26//!
27//! ## Example
28//!
29//! ```rust,no_run
30//! use rquest::Client;
31//! use rquest_util::Emulation;
32//!
33//! #[tokio::main]
34//! async fn main() -> Result<(), rquest::Error> {
35//! // Build a client to emulate Firefox135
36//! let client = Client::builder()
37//! .emulation(Emulation::Firefox135)
38//! .danger_accept_invalid_certs(true)
39//! .build()?;
40//!
41//! // Use the API you're already familiar with
42//! let text = client
43//! .get("https://tls.peet.ws/api/all")
44//! .send()
45//! .await?
46//! .text()
47//! .await?;
48//!
49//! println!("{}", text);
50//!
51//! Ok(())
52//! }
53//! ```
54
55#[cfg(feature = "emulation")]
56mod emulation;
57
58#[cfg(feature = "emulation")]
59pub use self::emulation::{Emulation, EmulationOS, EmulationOption};