module Ronin::Support::Network::HTTP::UserAgents
Contains built-in ‘User-Agent` strings for {HTTP}.
@api semipublic
@since 1.0.0
Constants
- ALIASES
Built-in ‘User-Agent` strings for impersonating various browsers.
Public Class Methods
[](id)
click to toggle source
Returns a ‘User-Agent` string for the given ID.
@param [:random, :chrome, :chrome_linux, :chrome_macos,
:chrome_windows, :chrome_iphone, :chrome_ipad, :chrome_android, :firefox, :firefox_linux, :firefox_macos, :firefox_windows, :firefox_iphone, :firefox_ipad, :firefox_android, :safari, :safari_macos, :safari_iphone, :safari_ipad, :edge, :linux, :macos, :windows, :iphone, :ipad, :android] id The new `User-Agent` string to use. The acceptable values are: * `:random` - a random value from {ALIASES} will be returned. * `:chrome` - a random Chrome `User-Agent` from {ALIASES} will be returned. * `:firefox` - a random Firefox `User-Agent` from {ALIASES} will be returned. * `:safari` - a random Safari `User-Agent` from {ALIASES} will be returned. * `:linux` - a random Linux `User-Agent` from {ALIASES} will be returned. * `:macos` - a random macOS `User-Agent` from {ALIASES} will be returned. * `:windows` - a random Windows `User-Agent` from {ALIASES} will be returned. * `:iphone` - a random iPhone `User-Agent` from {ALIASES} will be returned. * `:ipad` - a random iPad `User-Agent` from {ALIASES} will be returned. * `:android` - a random Android `User-Agent` from {ALIASES} will be returned. * Otherwise, the `User-Agent` String in {ALIASES} with the matching ID will be returned.
@return [String]
The `User-Agent` string for the given `id`.
@raise [ArgumentError]
The given `User-Agent` ID was not a known ID or wasn't a Symbol.
# File lib/ronin/support/network/http/user_agents.rb, line 94 def self.[](id) case id when :random ALIASES.values.sample when :chrome, :firefox, :safari # prefix ALIASES.select { |k,v| k =~ /^#{id}_/ }.values.sample when :linux, :macos, :windows, :iphone, :ipad, :android # suffix ALIASES.select { |k,v| k =~ /_#{id}$/ }.values.sample when Symbol ALIASES.fetch(id) do raise(ArgumentError,"unknown user agent alias: #{id.inspect}") end else raise(ArgumentError,"User-Agent ID must be a Symbol") end end