#user-agent #python-module #world #up #date #real #fake

fake-useragent

up to date simple useragent faker with real world database, inspired by python module fake-useragent

4 releases

0.1.3 Feb 10, 2019
0.1.2 Feb 10, 2019
0.1.1 Feb 9, 2019
0.1.0 Feb 9, 2019

#26 in #python-module

Download history 24/week @ 2024-11-16 66/week @ 2024-11-23 91/week @ 2024-11-30 57/week @ 2024-12-07 61/week @ 2024-12-14 39/week @ 2024-12-21 52/week @ 2024-12-28 39/week @ 2025-01-04 103/week @ 2025-01-11 162/week @ 2025-01-18 48/week @ 2025-01-25 111/week @ 2025-02-01 65/week @ 2025-02-08 53/week @ 2025-02-15 47/week @ 2025-02-22 61/week @ 2025-03-01

237 downloads per month
Used in 2 crates

MIT/Apache

19KB
314 lines

Intro

fake-useragent

Inspired by python module fake-useragent

Data from useragentstring.com (if failed to initialize, please make sure that you can access to this website)

Example

extern crate fake_useragent;

fn main() {
    // quick start
    {
        use fake_useragent::UserAgents;
        
        let user_agents = UserAgents::new();
        println!("{}", user_agents.random());
    }
    
    // from cache
    {
        use fake_useragent::UserAgents;
        
        let user_agents = UserAgents::from_cache("/tmp/user_agents");
        println!("{}", user_agents.random());
    }
    
    // customize
    {
        use fake_useragent::{Browser, UserAgentsBuilder};
        
        let user_agent = UserAgentsBuilder::new()
            .cache(false)                 // specify save to file or not, default true
            .dir("/tmp")                  // specify store path, default dir `./`; default filename `user_agents`
            .thread(20)                   // specify fetch thread, default 20
            .set_browsers(Browsers::new() // specify browsers
                .set_chrome()
                .set_firefox()
                .set_safari())
            .build();
        println!("{}", user_agent.random());        
    }
}

TODO

// selectable
let user_agents = UserAgents::new();
user_agents.chrome();
...

// more type
let user_agent = UserAgentsBuilder::new()
    .set_browsers(...)
    .set_crawlers(...)
    .set_link_checkers(...)
    .set_mobile_browsers(...)
    .build();

Dependencies

~23MB
~477K SLoC