Pumba.UserAgents (Pumba v0.0.2) View Source
Worker retrieves user agents for different browsers and provides random access to user agen strings.
Maintained state looks like
%{
client: Pumba.Client.DefaultClient,
browsers: %{},
names: []
}
Where browsers
is a map with key as browser
and the list user agents as value, names
is
a list of loaded browsers using which we later
can randomly pick browser and return a random user agent.
browsers
contains %Pumba.Result{}
record which keeps
total count of user agents and indexed map with user
agent strings for fast lookups.
It uses Pumba.Client.DefaultClient
which loads
user agent strings from http://www.useragentstring.com.
You can also specify you custom client via configuration
config :pumba,
client: MyAwesomeClient
Also you can override client using Pumba.UserAgents.set_client(MyAwesomeClient)
and clients should implement Pumba.Client
behaviour.
To load user agents list for a given browser you need to call Pumba.UserAgents.load/1
.
Link to this section Summary
Functions
Return current state.
Returns a specification to start this module under a supervisor.
Get list of user agents for browser
Asynchronously load user agents for given browser.
Returns random user agent string.
Check if user agents for a given browser were loaded
Replace client to retrieve user agents
Link to this section Functions
Specs
all() :: map()
Return current state.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Specs
Get list of user agents for browser
Specs
load(String.t()) :: :ok
Asynchronously load user agents for given browser.
Specs
random() :: term()
Returns random user agent string.
Specs
Check if user agents for a given browser were loaded
Specs
set_client(module()) :: :ok
Replace client to retrieve user agents