Sha256: 4a175c5d4629da3ad7f01d4e0f306abdef4d0fad0a8224a4ec0f918d5e5e0d62
Contents?: true
Size: 549 Bytes
Versions: 1
Compression:
Stored size: 549 Bytes
Contents
require 'uri' require 'open-uri' require 'nokogiri' require 'active_support/core_ext/object/to_query' require 'counting_stars/version' module CountingStars def self.count(query, site) request "#{query} site:#{site}" end def self.request(query) uri = URI::HTTPS.build( :host => 'encrypted.google.com', :path => '/search', :query => { :q => query }.to_query ) page = Nokogiri::HTML(open(uri)) page = page.css('div.slp').first.text page.gsub(/[[:space:]]/, ' ').lstrip.split(' - ') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
counting_stars-0.1.0 | lib/counting_stars.rb |