Class: Mbaidu
- Inherits:
-
SearchEngine
- Object
- SearchEngine
- Mbaidu
- Defined in:
- lib/baidu.rb
Constant Summary collapse
- BaseUri =
'http://m.baidu.com/s?'
- Options =
{:headers => headers}
Instance Method Summary collapse
-
#query(wd) ⇒ Object
基本查询,相当于从搜索框直接输入关键词查询.
Methods inherited from SearchEngine
Instance Method Details
#query(wd) ⇒ Object
基本查询,相当于从搜索框直接输入关键词查询
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/baidu.rb', line 112 def query(wd) queryStr = "word=#{wd}" uri = URI.encode((BaseUri + queryStr)) begin res = HTTParty.get(uri,Options) MbaiduResult.new(res,uri) rescue Exception => e warn "#{uri} fetch error: #{e.to_s}" return false end end |