Class: PageRankr::Indexes::Google
- Inherits:
-
Object
- Object
- PageRankr::Indexes::Google
- Includes:
- PageRankr::Index
- Defined in:
- lib/page_rankr/indexes/google.rb
Instance Attribute Summary
Attributes included from PageRankr::Index
Instance Method Summary collapse
-
#initialize(site) ⇒ Google
constructor
overloaded to use Google’s AJAX search API code.google.com/apis/ajaxsearch/documentation/.
- #request ⇒ Object
Methods included from PageRankr::Index
Constructor Details
#initialize(site) ⇒ Google
overloaded to use Google’s AJAX search API code.google.com/apis/ajaxsearch/documentation/
11 12 13 14 15 16 17 18 19 |
# File 'lib/page_rankr/indexes/google.rb', line 11 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 end |
Instance Method Details
#request ⇒ Object
21 22 23 24 |
# File 'lib/page_rankr/indexes/google.rb', line 21 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) end |