#user-agent #agent

rand_user_agent

Randomly generate common userAgents,used by spider

4 releases (2 breaking)

0.2.1 Sep 10, 2024
0.2.0 Sep 9, 2024
0.1.0 May 4, 2023
0.0.3 May 4, 2023
0.0.1 Apr 28, 2023

#160 in HTTP client

49 downloads per month
Used in translation_api

BSD-3-Clause

29KB
652 lines

This is a program that randomly generates UserAgents.

这是一个随机生成UserAgent的程序

Data From . 数据整理自

whatmyuseragent.com

user-agents.net

useragentstring.com

Quick Start

println!("{}", UserAgent::random().to_string());

Mobile and computer designated.手机电脑指定

// Random mobile agent. [随机手机端agent]
println!("Mobile:{}", UserAgent::mobile().to_string());
// Random Desktop agent.随机PC端
println!("Pc:{}", UserAgent::pc().to_string());

Fully customizable.完全自定义

BrowserDevicesDesktopDeviceMobileDevice impl rand::distributions::Standard

println!(
    "custom Mobile Iphone Chrome:{}",
    UserAgent::custom(Devices::Mobile(MobileDevice::Iphone), Browser::Chrome)
);
//first
println!(
    "custom Desktop Windows random browser :{}",
    UserAgent::custom(Devices::Desktop(DesktopDevice::Windows), rand::random())
);
//two
let mut rng = rand::thread_rng();
println!(
    "custom random Mobile & random browser :{}",
    UserAgent::custom(Devices::Mobile(rand::random()), Browser::random(&mut rng))
);

Todo

  • create Sec-CH-UA

Dependencies

~2.3–3.5MB
~59K SLoC