lib/page_rankr/indexes/google.rb in PageRankr-2.0.4 vs lib/page_rankr/indexes/google.rb in PageRankr-3.0.0
- old
+ new
@@ -1,27 +1,21 @@
-require 'typhoeus'
-require 'json'
+require File.expand_path('../../index', __FILE__)
module PageRankr
class Indexes
class Google
include Index
- # overloaded to use Google's AJAX search API
- # http://code.google.com/apis/ajaxsearch/documentation/
- def initialize(site)
- @site = site
-
- request.on_complete do |response|
- json = JSON.parse(response.body)
- @indexes = clean(json["responseData"]["cursor"]["estimatedResultCount"].to_s)
- @indexes = nil if @indexes.zero?
- end
+ def url
+ "http://www.google.com/search"
end
-
- def request
- @request ||= Typhoeus::Request.new("http://ajax.googleapis.com/ajax/services/search/web",
- :params => {:v => "1.0", :rsz => 1, :q => "site:#{@site.to_s}"}, :method => :get)
+
+ def params
+ {:q => "site:#{@site.to_s}"}
+ end
+
+ def xpath
+ "//div[@id='resultStats']/text()"
end
end
end
end
\ No newline at end of file