15 releases

0.4.2 May 3, 2024
0.3.6 Mar 20, 2024
0.3.5 Dec 30, 2022
0.3.2 Sep 19, 2022
0.3.0 Jul 25, 2022

#610 in Web programming

Download history 15/week @ 2024-01-22 78/week @ 2024-01-29 20/week @ 2024-02-05 41/week @ 2024-02-12 162/week @ 2024-02-19 197/week @ 2024-02-26 96/week @ 2024-03-04 72/week @ 2024-03-11 272/week @ 2024-03-18 118/week @ 2024-03-25 194/week @ 2024-04-01 51/week @ 2024-04-08 129/week @ 2024-04-15 106/week @ 2024-04-22 576/week @ 2024-04-29 446/week @ 2024-05-06

1,261 downloads per month
Used in 8 crates (2 directly)

MIT license

15KB
233 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
~26K SLoC