Session-sticky User-Agent rotation with full, modern browser profiles.
Assigns one random browser profile per session (keyed however you like —
e.g. {user_id, host}). Every request during that session reuses the
same UA + Accept-Language; after 30 minutes of inactivity the profile
expires. Rotating a consistent identity per session looks far more like
a real client than a fresh random UA on every request.
Guise.headers("https://example.com/")
#=> [{"user-agent", "Mozilla/5.0 …"}, {"referer", "https://example.com/"}]
Guise.headers("https://example.com/", {user_id, "example.com"})
#=> sticky UA + accept-language + referer for that session keyHow the pool stays fresh
A modern UA string is a stable template plus one volatile part — the
browser's major version (Chrome froze everything below the major to
.0.0.0 years ago). So instead of a list of frozen strings that all rot
together, the pool is rendered from @specs (engine × OS × weight) using
a small version table in priv/versions.json. Bumping those few versions
modernizes the whole pool at once and can't produce an inconsistent
string. Refresh the table with:
mix guise.refreshwhich pulls the current stable majors from endoflife.date and rewrites the JSON. The runtime never touches the network — it only reads the committed file at boot.
Configuration
Override individual browser versions (handy for tests or pinning):
config :guise, Guise,
versions: %{"chrome" => "140.0.0.0"}Or replace the pool wholesale with your own profiles — each a map with a
required :ua and optional :accept_language (default en-US) and
:weight (default 1); a bare string is taken as the UA. When
:profiles is set it wins over the built-in specs and :versions is
ignored:
config :guise, Guise,
profiles: [
%{ua: "MyBot/1.0 (+https://example.com/bot)", weight: 3},
"Mozilla/5.0 (…) Chrome/140.0.0.0 Safari/537.36"
]
Summary
Functions
Returns a specification to start this module under a supervisor.
Returns a sticky browser profile for the given session key, creating one if needed.
Returns headers with a random User-Agent and the given referer.
Returns headers with a session-sticky User-Agent, Accept-Language, and the given referer.
The full rendered pool (UA strings) — for inspection/tests.
Returns a random (share-weighted) User-Agent string.
The version table currently in effect (file + config overrides merged).
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Returns a sticky browser profile for the given session key, creating one if needed.
Returns headers with a random User-Agent and the given referer.
Returns headers with a session-sticky User-Agent, Accept-Language, and the given referer.
The full rendered pool (UA strings) — for inspection/tests.
Returns a random (share-weighted) User-Agent string.
The version table currently in effect (file + config overrides merged).