baidu_web 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/baidu_web.rb +3 -3
- data/lib/baidu_web/version.rb +1 -1
- metadata +1 -1
data/lib/baidu_web.rb
CHANGED
@@ -5,6 +5,7 @@ require 'mechanize'
|
|
5
5
|
require 'hpricot'
|
6
6
|
require 'open-uri'
|
7
7
|
require 'cgi'
|
8
|
+
require 'iconv'
|
8
9
|
require "baidu_web/version"
|
9
10
|
require "baidu_web/record"
|
10
11
|
require "baidu_web/extension_key"
|
@@ -16,12 +17,11 @@ module BaiduWeb
|
|
16
17
|
def search(key_word, options)
|
17
18
|
result = {:record_arr => [], :ext_key_arr => [], :source => 'web'}
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
@ic2 = Iconv.new('gb2312//IGNORE', 'UTF-8//IGNORE')
|
21
21
|
@key_word = key_word
|
22
22
|
return result if @key_word.blank?
|
23
23
|
#uri parser key word
|
24
|
-
@key_word = CGI.escape(@key_word)
|
24
|
+
@key_word = CGI.escape(@ic2.iconv(@key_word))
|
25
25
|
|
26
26
|
#determine how many records display on one page. (same as www.baidu.com/?<some params>&rn=50)
|
27
27
|
@per_page = options[:per_page]
|
data/lib/baidu_web/version.rb
CHANGED