Skip to main content

get_random_user_agent_from_pool

Function get_random_user_agent_from_pool 

Source
pub fn get_random_user_agent_from_pool(pool: &[String]) -> String
Expand description

Get a random user agent from pool

§Arguments

  • pool - Slice of user agent strings

§Returns

A randomly selected user agent string

§Examples

use rust_scraper::user_agent::get_random_user_agent_from_pool;

let agents = vec!["Chrome/131".to_string(), "Firefox/123".to_string()];
let ua = get_random_user_agent_from_pool(&agents);
assert!(ua == "Chrome/131" || ua == "Firefox/123");