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.

fetch_ssllabs_useragent 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env ruby
  2. require 'httparty'
  3. require 'nokogiri'
  4. require 'nokogiri-pretty'
  5. require 'open-uri'
  6. uas = Nokogiri::HTML open 'https://www.ssllabs.com/ssltest/clients.html'
  7. uas = Hash[uas.css('#multiTable > tr > td:first > a').collect do |ua|
  8. ua_url = ua.attr :href
  9. ua = Nokogiri::HTML open "https://www.ssllabs.com/ssltest/#{ua_url}"
  10. name = ua.at_css('h1').text.sub('User Agent Capabilities:', '').strip
  11. puts name
  12. reports = ua.css '.reportTable'
  13. protocols = Hash[reports[0].css('tr').collect do |protocol|
  14. protocol, support = protocol.css 'td'
  15. next if protocol.attr(:class) == 'tableHead'
  16. protocol = protocol.text.sub("\xC2\xA0 INSECURE", '').strip
  17. support = support.text == 'Yes'
  18. [protocol, support]
  19. end.reject &:nil?]
  20. ciphers = Hash[reports[1].css('tr').collect do |cipher|
  21. cipher, size = cipher.css 'td'
  22. next if cipher.attr(:class) == 'tableHead' or size.nil?
  23. cipher = /(.*) \(0x(.*)\).*/.match cipher.text
  24. cipher = ["0x#{cipher[2].upcase.rjust(2, '0')}", cipher[1]]
  25. end.reject &:nil?]
  26. [name, { protocols: protocols, ciphers: ciphers }]
  27. end]
  28. File.write 'config/user-agent.json', JSON.pretty_generate(uas, {indent: "\t"})