12 releases

0.3.6 Mar 20, 2024
0.3.5 Dec 30, 2022
0.3.2 Sep 19, 2022
0.3.0 Jul 25, 2022
0.1.1 Jun 8, 2022

#9 in #user-agent

Download history 38/week @ 2023-12-06 158/week @ 2023-12-13 72/week @ 2023-12-20 155/week @ 2023-12-27 59/week @ 2024-01-03 40/week @ 2024-01-10 401/week @ 2024-01-17 35/week @ 2024-01-24 60/week @ 2024-01-31 26/week @ 2024-02-07 110/week @ 2024-02-14 153/week @ 2024-02-21 158/week @ 2024-02-28 85/week @ 2024-03-06 105/week @ 2024-03-13 228/week @ 2024-03-20

596 downloads per month
Used in 2 crates

MIT license

10KB
116 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/a11ywatch/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 API Layer User Agent 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.

TODO

  1. Update user-agent list via CRON github actions.

Dependencies

~0–1MB
~26K SLoC