Crate rquest_util

Source
Expand description

§rquest-util

CI MIT licensed crates.io docs.rs Crates.io Total Downloads

A collection of utilities to do common things with rquest.

§Emulation

  • Emulation Device

    In fact, most device models have the same TLS/HTTP2 configuration, except that the User-Agent is changed.

    §Default device emulation types

    BrowserVersions
    ChromeChrome100, 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
    EdgeEdge101, Edge122, Edge127, Edge131, Edge134
    SafariSafariIos17_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
    OkHttpOkHttp3_9, OkHttp3_11, OkHttp3_13, OkHttp3_14, OkHttp4_9, OkHttp4_10, OkHttp4_12, OkHttp5
    FirefoxFirefox109, Firefox117, Firefox128, Firefox133, Firefox135, FirefoxPrivate135, FirefoxAndroid135, Firefox136, FirefoxPrivate136

§Example

use rquest::Client;
use rquest_util::Emulation;

#[tokio::main]
async fn main() -> Result<(), rquest::Error> {
    // Build a client to emulate Firefox135
    let client = Client::builder()
        .emulation(Emulation::Firefox135)
        .danger_accept_invalid_certs(true)
        .build()?;

    // Use the API you're already familiar with
    let text = client
        .get("https://tls.peet.ws/api/all")
        .send()
        .await?
        .text()
        .await?;

    println!("{}", text);

    Ok(())
}

Macros§

conditional_http2
header_chrome_accpet
header_chrome_sec_ch_ua
header_chrome_sec_fetch
header_chrome_ua
header_firefox_accept
header_firefox_sec_fetch
header_firefox_ua
join

Structs§

EmulationOption
Represents the configuration options for emulating a browser and operating system.

Enums§

Emulation
Represents different browser versions for impersonation.
EmulationOS
Represents different operating systems for impersonation.