Class: Qihoo

Inherits:
SearchEngine show all
Defined in:
lib/baidu.rb

Constant Summary collapse

Host =
'www.so.com'

Instance Method Summary collapse

Methods inherited from SearchEngine

#indexed?

Instance Method Details

#query(wd) ⇒ Object

基本查询, 相当于在搜索框直接数据关键词查询



56
57
58
59
60
61
62
63
# File 'lib/baidu.rb', line 56

def query(wd)
    #用原始路径请求
    uri = URI.join("http://#{Host}/",URI.encode('s?q='+wd)).to_s
    body = HTTParty.get(uri)
    #如果请求地址被跳转,重新获取当前页的URI,可避免翻页错误
    uri = URI.join("http://#{Host}/",body.request.path).to_s
    QihooResult.new(body,uri)
end