lib/page_rankr/ranks/google.rb in PageRankr-2.0.4 vs lib/page_rankr/ranks/google.rb in PageRankr-3.0.0

- old
+ new

@@ -1,32 +1,28 @@ -require 'typhoeus' -require File.join(File.dirname(__FILE__), "google", "checksum") +require File.expand_path('../../rank', __FILE__) +require File.expand_path('../google/checksum', __FILE__) module PageRankr class Ranks class Google include Rank def initialize(site) - @site = site - @checksum = Checksum.generate(@site.to_s) + @checksum = Checksum.generate(site.to_s) + + super(site) + end - request.on_complete do |response| - @rank = if response.body =~ regex - clean($1) - else - nil - end - end + def url + "http://toolbarqueries.google.com/tbr" end - def regex - /Rank_\d+:\d+:(\d+)/ + def params + {:client => "navclient-auto", :ch => @checksum, :features => "Rank", :q => "info:#{@site.to_s}"} end - def request - @request ||= Typhoeus::Request.new("http://toolbarqueries.google.com/tbr", - :params => {:client => "navclient-auto", :ch => @checksum, :features => "Rank", :q => "info:#{@site.to_s}"}) + def regex + /Rank_\d+:\d+:(\d+)/ end end end end