rquest_util/
lib.rs

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