Sha256: d203125527fc659def95287d9135ceef02dfa05ded9a71496620d8726ecf9459

Contents?: true

Size: 566 Bytes

Versions: 3

Compression:

Stored size: 566 Bytes

Contents

path = File.expand_path(File.dirname(__FILE__)) + '/google/'
require "open-uri"
require path + 'checksum'

module PageRankr
  module Google
    class << self
      def lookup(site)
        checksum = Checksum.generate(site)
        begin
          open(url(site, checksum)) {|io| io.read.scan(/Rank_\d+:\d+:(\d+)/)[0][0].to_i}
        rescue
          -1
        end
      end

      private

      def url(site, checksum)
        "http://toolbarqueries.google.com/search?client=navclient-auto&ch=#{checksum}&features=Rank&q=info:#{site}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
PageRankr-1.2.0 lib/page_rankr/google.rb
PageRankr-1.1.0 lib/page_rankr/google.rb
PageRankr-1.0.0 lib/page_rankr/google.rb