Sha256: 3489258a03110d267816306a5d87e7f75033b508cc02e7b2c765e356306f442d

Contents?: true

Size: 600 Bytes

Versions: 2

Compression:

Stored size: 600 Bytes

Contents

require "open-uri"
require File.join("page_rankr", "ranks", "google", "checksum")

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

      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

2 entries across 2 versions & 1 rubygems

Version Path
PageRankr-1.4.3 lib/page_rankr/ranks/google.rb
PageRankr-1.4.2 lib/page_rankr/ranks/google.rb