20 releases

0.5.4 Dec 1, 2024
0.5.3 Oct 25, 2024
0.5.1 Jul 14, 2024
0.3.6 Mar 20, 2024
0.3.0 Jul 25, 2022

#842 in Web programming

Download history 355/week @ 2024-08-18 935/week @ 2024-08-25 591/week @ 2024-09-01 606/week @ 2024-09-08 544/week @ 2024-09-15 1078/week @ 2024-09-22 1144/week @ 2024-09-29 1433/week @ 2024-10-06 448/week @ 2024-10-13 1420/week @ 2024-10-20 1564/week @ 2024-10-27 1400/week @ 2024-11-03 593/week @ 2024-11-10 959/week @ 2024-11-17 1724/week @ 2024-11-24 2210/week @ 2024-12-01

5,595 downloads per month
Used in 12 crates (2 directly)

MIT license

21KB
330 lines

ua_generator

Generate random real User-Agents to use as spoofs.

How to use

Example of generating a randomized user agent updated weekly.

cargo add ua_generator --git https://github.com/spider-rs/ua_generator.git
use ua_generator::ua::spoof_ua;

fn main() {
    let ua = spoof_ua();

    println!("{}", ua);
    // Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36
};

The static files are checked and generated from the build.rs file to prevent extra need for API calls since they are limited and require authentication.

If you plan on using this building locally you need a valid API key from the Spider Cloud API and set the value to the env var APILAYER_KEY. You can run BUILD_ENABLED=1 APILAYER_KEY=$APILAYER_KEY cargo build to generate the static files. You can also change the API endpoint using the env variable API_URL.


lib.rs:

Generate a random User-Agent to use.

UA generator generates a randomized current User-Agent.

How to use UA_Generator

  • Generate get a random UA to use.

Basic usage

First, you will need to add ua_generator to your Cargo.toml.

Next, simply add the ua_generator::ua::spoof_ua() to get your random agent.

Dependencies

~0–1MB
~24K SLoC