Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/emulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use wreq_util::Emulation;
async fn main() -> Result<(), wreq::Error> {
// Build a client to emulation Firefox136
let client = Client::builder()
.emulation(Emulation::Firefox109)
.emulation(Emulation::Firefox139)
.cert_verification(false)
.build()?;

// Use the API you're already familiar with
let text = client
.get("https://tls.peet.ws/api/all")
.get("https://tls.browserleaks.com/")
.send()
.await?
.text()
Expand Down
99 changes: 99 additions & 0 deletions src/emulation/device/chrome/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,3 +1133,102 @@ mod_generator!(
)
]
);

mod_generator!(
v138,
v132::build_emulation,
header_initializer_with_zstd_priority,
[
(
MacOS,
r#""Chromium";v="138", "Not=A?Brand";v="24", "Google Chrome";v="138""#,
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
),
(
Linux,
r#""Chromium";v="138", "Not=A?Brand";v="24", "Google Chrome";v="138""#,
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
),
(
Android,
r#""Chromium";v="138", "Not=A?Brand";v="24", "Google Chrome";v="138""#,
"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36"
),
(
Windows,
r#""Chromium";v="138", "Not=A?Brand";v="24", "Google Chrome";v="138""#,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
),
(
IOS,
r#""Chromium";v="138", "Not=A?Brand";v="24", "Google Chrome";v="138""#,
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/138.0.0.0 Mobile/15E148 Safari/604.1"
)
]
);

mod_generator!(
v139,
v132::build_emulation,
header_initializer_with_zstd_priority,
[
(
MacOS,
r#""Chromium";v="139", "Not=A?Brand";v="24", "Google Chrome";v="139""#,
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
),
(
Linux,
r#""Chromium";v="139", "Not=A?Brand";v="24", "Google Chrome";v="139""#,
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
),
(
Android,
r#""Chromium";v="139", "Not=A?Brand";v="24", "Google Chrome";v="139""#,
"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Mobile Safari/537.36"
),
(
Windows,
r#""Chromium";v="139", "Not=A?Brand";v="24", "Google Chrome";v="139""#,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
),
(
IOS,
r#""Chromium";v="139", "Not=A?Brand";v="24", "Google Chrome";v="139""#,
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/139.0.0.0 Mobile/15E148 Safari/604.1"
)
]
);

mod_generator!(
v140,
v132::build_emulation,
header_initializer_with_zstd_priority,
[
(
MacOS,
r#""Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140""#,
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"
),
(
Linux,
r#""Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140""#,
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"
),
(
Android,
r#""Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140""#,
"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36"
),
(
Windows,
r#""Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140""#,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"
),
(
IOS,
r#""Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140""#,
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/140.0.0.0 Mobile/15E148 Safari/604.1"
)
]
);
56 changes: 56 additions & 0 deletions src/emulation/device/firefox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,59 @@ mod_generator!(
)
]
);

mod_generator!(
ff142,
ff135::build_emulation,
header_initializer_with_zstd,
[
(
Windows,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0) Gecko/20100101 Firefox/142.0"
),
(
MacOS,
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:142.0) Gecko/20100101 Firefox/142.0"
),
(
Linux,
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0"
),
(
Android,
"Mozilla/5.0 (Android 13; Mobile; rv:142.0) Gecko/142.0 Firefox/142.0"
),
(
IOS,
"Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/142.0 Mobile/15E148 Safari/605.1.15"
)
]
);

mod_generator!(
ff143,
ff135::build_emulation,
header_initializer_with_zstd,
[
(
Windows,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0"
),
(
MacOS,
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:143.0) Gecko/20100101 Firefox/143.0"
),
(
Linux,
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:143.0) Gecko/20100101 Firefox/143.0"
),
(
Android,
"Mozilla/5.0 (Android 13; Mobile; rv:143.0) Gecko/143.0 Firefox/143.0"
),
(
IOS,
"Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/143.0 Mobile/15E148 Safari/605.1.15"
)
]
);
10 changes: 10 additions & 0 deletions src/emulation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ define_emulation_enum!(
Chrome135 => "chrome_135",
Chrome136 => "chrome_136",
Chrome137 => "chrome_137",
Chrome138 => "chrome_138",
Chrome139 => "chrome_139",
Chrome140 => "chrome_140",

SafariIos17_2 => "safari_ios_17.2",
SafariIos17_4_1 => "safari_ios_17.4.1",
Expand Down Expand Up @@ -135,6 +138,8 @@ define_emulation_enum!(
Firefox136 => "firefox_136",
FirefoxPrivate136 => "firefox_private_136",
Firefox139 => "firefox_139",
Firefox142 => "firefox_142",
Firefox143 => "firefox_143",

Opera116 => "opera_116",
Opera117 => "opera_117",
Expand Down Expand Up @@ -301,6 +306,9 @@ impl wreq::EmulationFactory for EmulationOption {
Emulation::Chrome135 => v135::emulation,
Emulation::Chrome136 => v136::emulation,
Emulation::Chrome137 => v137::emulation,
Emulation::Chrome138 => v138::emulation,
Emulation::Chrome139 => v139::emulation,
Emulation::Chrome140 => v140::emulation,

Emulation::SafariIos17_2 => safari_ios_17_2::emulation,
Emulation::SafariIos17_4_1 => safari_ios_17_4_1::emulation,
Expand Down Expand Up @@ -347,6 +355,8 @@ impl wreq::EmulationFactory for EmulationOption {
Emulation::Firefox136 => ff136::emulation,
Emulation::FirefoxPrivate136 => ff_private_136::emulation,
Emulation::Firefox139 => ff139::emulation,
Emulation::Firefox142 => ff142::emulation,
Emulation::Firefox143 => ff143::emulation,

Emulation::Opera116 => opera116::emulation,
Emulation::Opera117 => opera117::emulation,
Expand Down
14 changes: 14 additions & 0 deletions tests/emulation_firefox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,17 @@ test_emulation!(
["t13d1717h2_5b57614c22b0_3cbfd9057e0d"],
"6ea73faa8fc5aac76bded7bd238f6433"
);

test_emulation!(
test_firefox_142,
Emulation::Firefox142,
["t13d1717h2_5b57614c22b0_3cbfd9057e0d"],
"6ea73faa8fc5aac76bded7bd238f6433"
);

test_emulation!(
test_firefox_143,
Emulation::Firefox143,
["t13d1717h2_5b57614c22b0_3cbfd9057e0d"],
"6ea73faa8fc5aac76bded7bd238f6433"
);
Loading