Sha256: 1eab8f9e37504279e4266017f27aa206d7427154a7aafb469ce54b19fe8d6ce6

Contents?: true

Size: 600 Bytes

Versions: 1

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)
        begin
          @rank = 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

1 entries across 1 versions & 1 rubygems

Version Path
PageRankr-1.4.0 lib/page_rankr/ranks/google.rb