Module: Ronin::Web::UserAgents::GoogleBot
- Defined in:
- lib/ronin/web/user_agents/google_bot.rb
Overview
Represents every possible GoogleBot
User-Agent
string.
Constant Summary collapse
- VERSION =
GoogleBot
version '2.1'
- URL =
`GoogleBot' URL.
'http://www.google.com/bot.html'
- ANDROID_VERSION =
The Android version which
GoogleBot
Mobile uses. '6.0.1'
- ANDROID_DEVICE =
The Android device which
GoogleBot
Mobile uses. 'Nexus 5X Build/MMB29P'
- SUPPORTED_CRAWLERS =
Supported
crawler:
values. [:search, :image, :video]
- SUPPORTED_COMPATIBILITY_MODES =
Supported
compatible:
values. [:desktop, :mobile, nil]
- KNOWN_CHROME_VERSIONS =
Known Chrome versions.
Chrome::KNOWN_VERSIONS
Class Method Summary collapse
-
.build(crawler: :search, compatible: nil, chrome_version: nil) ⇒ String
Builds a
GoogleBot
User-Agent
string. -
.random(crawler: SUPPORTED_CRAWLERS.sample, compatible: SUPPORTED_COMPATIBILITY_MODES.sample, chrome_version: KNOWN_CHROME_VERSIONS.sample) ⇒ String
Builds a random
GoogleBot
User-Agent
string.
Class Method Details
.build(crawler: :search, compatible: nil, chrome_version: nil) ⇒ String
Builds a GoogleBot
User-Agent
string.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ronin/web/user_agents/google_bot.rb', line 66 def self.build(crawler: :search, compatible: nil, chrome_version: nil) case crawler when :image "Googlebot-Image/1.0" when :video "Googlebot-Video/1.0" when :search case compatible when :desktop googlebot = "GoogleBot/#{VERSION}; +#{URL}" if chrome_version "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; #{googlebot}) Chrome/#{chrome_version} Safari/537.36" else "Mozilla/5.0 (compatible; #{googlebot})" end when :mobile unless chrome_version raise(ArgumentError,"compatible: :mobile also requires the chrome_version: keyword argument") end "Mozilla/5.0 (Linux; Android #{ANDROID_VERSION}; #{ANDROID_DEVICE}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/#{chrome_version} Mobile Safari/537.36 (compatible; GoogleBot/#{VERSION}; +#{URL})" when nil "GoogleBot/#{VERSION} (+#{URL})" else raise(ArgumentError,"unsupported compatible: value (#{compatible.inspect})") end else raise(ArgumentError,"unsupported crawler: value (#{crawler.inspect})") end end |
.random(crawler: SUPPORTED_CRAWLERS.sample, compatible: SUPPORTED_COMPATIBILITY_MODES.sample, chrome_version: KNOWN_CHROME_VERSIONS.sample) ⇒ String
Builds a random GoogleBot
User-Agent
string.
128 129 130 131 132 133 134 135 136 |
# File 'lib/ronin/web/user_agents/google_bot.rb', line 128 def self.random(crawler: SUPPORTED_CRAWLERS.sample, compatible: SUPPORTED_COMPATIBILITY_MODES.sample, chrome_version: KNOWN_CHROME_VERSIONS.sample) build( crawler: crawler, compatible: compatible, chrome_version: chrome_version ) end |