Sha256: 78da42e3add13e679d729bf8a38efc1fc6cdd547a08b9bfc08e3bac529d668db

Contents?: true

Size: 580 Bytes

Versions: 9

Compression:

Stored size: 580 Bytes

Contents

require 'timeout'
require 'net/http'
require 'nokogiri'

module Impressionist
  module Bots
    LIST_URL = "http://www.user-agents.org/allagents.xml"
    def self.consume
      Timeout.timeout(4) do
        response = Net::HTTP.get(URI.parse(LIST_URL))
        doc = Nokogiri::XML(response)
        list = []
        doc.xpath('//user-agent').each do |agent|
          type = agent.xpath("Type").text
          list << agent.xpath("String").text.gsub("&lt;","<") if ["R","S"].include?(type) #gsub hack for badly formatted data
        end
        list
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
impressionist-cody-2.0.0 lib/impressionist/bots.rb
impressionist-2.0.0 lib/impressionist/bots.rb
impressionist-1.6.1 lib/impressionist/bots.rb
impressionist-1.6.0 lib/impressionist/bots.rb
impressionist-1.5.2 lib/impressionist/bots.rb
impressionist2-1.5.5 lib/impressionist/bots.rb
impressionist2-1.5.4 lib/impressionist/bots.rb
impressionist2-1.5.3 lib/impressionist/bots.rb
impressionist2-1.5.1 lib/impressionist/bots.rb