Module: Ronin::Web::UserAgents::InternetArchive

Defined in:
lib/ronin/web/user_agents/internet_archive.rb

Constant Summary collapse

HEX_CHARS =
%w[0 1 2 3 4 5 6 7 8 9 a b c d e f]

Class Method Summary collapse

Class Method Details

.build(date:, bot_id:) ⇒ String

Builds an Internet Archive crawler User-Agent string.

Parameters:

  • date (Date)

    The date to embed into the User-Agent string.

  • bot_id (String)

    The bot ID to embed in the User-Agent string.

Returns:

  • (String)

    The Internet Archive User-Agent string.



48
49
50
51
52
# File 'lib/ronin/web/user_agents/internet_archive.rb', line 48

def self.build(date: , bot_id: )
  timestamp = date.strftime("%Y%m%d")

  return "ArchiveTeam ArchiveBot/#{timestamp}.#{bot_id} (wpull 2.0.3) and not Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"
end

.random(date: Date.today, bot_id: random_hex_id) ⇒ String

Generates a random Internet Archive User-Agent String.

Parameters:

  • date (Date) (defaults to: Date.today)

    The date to embed into the User-Agent string.

  • bot_id (String) (defaults to: random_hex_id)

    The bot ID to embed in the User-Agent string.

Returns:

  • (String)

    A random Internet Archive User-Agent string.



66
67
68
# File 'lib/ronin/web/user_agents/internet_archive.rb', line 66

def self.random(date: Date.today, bot_id: random_hex_id)
  build(date: date, bot_id: bot_id)
end

.random_hex_idString

Generates a random hex ID.

Returns:

  • (String)


32
33
34
# File 'lib/ronin/web/user_agents/internet_archive.rb', line 32

def self.random_hex_id
  Array.new(7) { HEX_CHARS.sample }.join
end