You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1 KiB

#!/usr/bin/env ruby
require 'httparty'
require 'nokogiri'
require 'nokogiri-pretty'
require 'open-uri'
uas = Nokogiri::HTML open ''
uas = Hash[uas.css('#multiTable > tr > td:first > a').collect do |ua|
ua_url = ua.attr :href
ua = Nokogiri::HTML open "{ua_url}"
name = ua.at_css('h1').text.sub('User Agent Capabilities:', '').strip
puts name
reports = ua.css '.reportTable'
protocols = Hash[reports[0].css('tr').collect do |protocol|
protocol, support = protocol.css 'td'
next if protocol.attr(:class) == 'tableHead'
protocol = protocol.text.sub("\xC2\xA0 INSECURE", '').strip
support = support.text == 'Yes'
[protocol, support]
end.reject &:nil?]
ciphers = Hash[reports[1].css('tr').collect do |cipher|
cipher, size = cipher.css 'td'
next if cipher.attr(:class) == 'tableHead' or size.nil?
cipher = /(.*) \(0x(.*)\).*/.match cipher.text
cipher = ["0x#{cipher[2].upcase.rjust(2, '0')}", cipher[1]]
end.reject &:nil?]
[name, { protocols: protocols, ciphers: ciphers }]
File.write 'config/user-agent.json', JSON.pretty_generate(uas, {indent: "\t"})