forked from charlotte-ruby/impressionist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removing httpclient due to deprecation warning
- Loading branch information
spodlecki
committed
Dec 30, 2015
1 parent
aae4292
commit b38845a
Showing
3 changed files
with
14 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
require 'httpclient' | ||
require 'timeout' | ||
require 'net/http' | ||
require 'nokogiri' | ||
|
||
module Impressionist | ||
module Bots | ||
LIST_URL = "http://www.user-agents.org/allagents.xml" | ||
def self.consume | ||
response = HTTPClient.new.get_content(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("<","<") if ["R","S"].include?(type) #gsub hack for badly formatted data | ||
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("<","<") if ["R","S"].include?(type) #gsub hack for badly formatted data | ||
end | ||
list | ||
end | ||
list | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters