Class: ESearchy::SearchEngines::Google

Inherits:
GenericEngine show all
Defined in:
lib/esearchy/SearchEngines/google.rb

Constant Summary collapse

ENGINE =
"www.google.com"
PORT =
80
NUM =
100
TYPE =
1

Instance Attribute Summary

Attributes inherited from GenericEngine

#documents, #emails, #people, #results

Instance Method Summary collapse

Methods inherited from GenericEngine

#company=, #initialize, #maxhits=, #start=

Constructor Details

This class inherits a constructor from ESearchy::GenericEngine

Instance Method Details

#parse(html) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/esearchy/SearchEngines/google.rb', line 14

def parse( html )
  hits = html.scan(/<\/b> of [\w\s]*<b>(.*)<\/b> for /)
  if hits.empty? or hits == nil
    @totalhits = 0
  else
    @totalhits = totalhits(hits[0][0].gsub(",","").to_i)
  end
  super html.scan(/<div class=g><span class="b w xsm">\[([A-Z]+)\]<\/span> \
<h2 class=r><a href="([0-9A-Za-z:\\\/?&=@+%.;"'()_-]+)"|<h2 class=r><a href="\
([0-9A-Za-z:\\\/?&=@+%.;"'()_-]+)"/)
end

#searchObject



9
10
11
12
# File 'lib/esearchy/SearchEngines/google.rb', line 9

def search 
  @querypath = "/cse?&safe=off&num=100&site=&q=" +  @query  + "&btnG=Search&start="
  super
end