Class: Query::Engine::QihuMobile

Inherits:
Object
  • Object
show all
Defined in:
lib/query/engine/qihu_mobile.rb

Constant Summary collapse

Host =
"m.haosou.com"
Options =
{
:headers => {"User-Agent" => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11'}
}

Class Method Summary collapse

Class Method Details

.query(wd, params = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/query/engine/qihu_mobile.rb', line 8

def self.query(wd, params={})
  q = Array.new
  q << "q=#{URI.encode(wd)}"
  #q << "rn=#{@perpage.to_i}" if @perpage
  # Join arguments
  params.each do |k, v|
    q << "#{k.to_s}=#{v.to_s}"
  end
  uri = URI::HTTP.build(:host=>Host,:path=>'/s',:query=>q.join('&'))
  res = HTTParty.get(uri, Options)
  r = Query::Result::QihuMobile.new(res)
  r.baseuri, r.options = uri, Options  
  r
end