Module: HTTP::UserAgent

Defined in:
lib/http_validator.rb

Class Method Summary collapse

Class Method Details

.getObject



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/http_validator.rb', line 111

def self.get
  save_to = File.expand_path(File.dirname(__FILE__) + '/../config/user_agents.yaml')
  agents = []
  @browser.url = 'http://www.useragentstring.com/pages/All/'
  @browser.perform
  doc = Nokogiri::HTML(@browser.body_str)

  fd = File.open(save_to, 'w+')
  doc.search("//ul").each { |ul|
    ul.search("//li").each { |li|
      li.search("//a").each { |a|
        fd.puts a.text
      }
    }
  }
  fd.close
end