peertracker/ruby/lib/as_parser.rb
2013-01-25 10:29:36 +01:00

24 lines
459 B
Ruby

class ASParser
def parse_response(response)
[parse_as(response),parse_country(response)]
end
def parse_as(response)
begin
response.scan(/Provider:<\/b><p>(\w*)/)[0][0]
rescue => e
puts "Could not parse AS"
nil
end
end
def parse_country(response)
begin
response.scan(/Location:<\/b><p>(.*)<p>/)[0][0].split(",").last.strip
rescue => e
puts "Could not parse Country"
nil
end
end
end