fake-useragent
Inspired by python module fake-useragent
Data from useragentstring.com (if failed to initialize, make sure you can access this website)
```rust 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());
}
} ```
```rust // selectable let useragents = UserAgents::new(); useragents.chrome(); ...
// more type let useragent = UserAgentsBuilder::new() .setbrowsers(...) .setcrawlers(...) .setlinkcheckers(...) .setmobile_browsers(...) .build(); ```