Skip to content

Instantly share code, notes, and snippets.

@jakeonrails
Forked from Sjors/robot_user_agents.rb
Created October 15, 2012 21:37

Revisions

  1. @Sjors Sjors revised this gist Aug 3, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion robot_user_agents.rb
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,4 @@
    xml_data = Net::HTTP.get_response(URI.parse(url)).body
    data = XmlSimple.xml_in(xml_data)
    agents = data['user-agent'].select{|agent| type = agent["Type"].first; type.include?("R") || type.include?("S")}
    agent_names = agents.collect {|agent| agent["String"]}
    agent_names = agents.collect {|agent| agent["String"].first}
  2. @Sjors Sjors created this gist Aug 3, 2011.
    7 changes: 7 additions & 0 deletions robot_user_agents.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    require 'net/http'
    require 'xmlsimple'
    url = "http://www.user-agents.org/allagents.xml"
    xml_data = Net::HTTP.get_response(URI.parse(url)).body
    data = XmlSimple.xml_in(xml_data)
    agents = data['user-agent'].select{|agent| type = agent["Type"].first; type.include?("R") || type.include?("S")}
    agent_names = agents.collect {|agent| agent["String"]}