baidu_web 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -7,6 +7,12 @@ Baidu_web是一个基于百度的元搜索引擎,输入关键字,返还百
7
7
 
8
8
  gem 'baidu_web'
9
9
 
10
+ ## 依赖项
11
+
12
+ require 'mechanize'
13
+ require 'hpricot'
14
+ require 'open-uri'
15
+
10
16
  ## 调用
11
17
 
12
18
  # http://www.baidu.com/s?wd=inruby&pn=100&rn=50
@@ -31,6 +37,10 @@ Baidu_web是一个基于百度的元搜索引擎,输入关键字,返还百
31
37
  ## 在irb中测试:
32
38
 
33
39
  $:.unshift(File.dirname(__FILE__))
40
+ require 'mechanize'
41
+ require 'hpricot'
42
+ require 'open-uri'
34
43
  require 'baidu_web'
35
44
  require 'cgi'
36
45
  result = BaiduWeb.search(CGI.escape("游戏"), :per_page => 10, :page_index => 1)
46
+ result = BaiduWeb.search("ruby", :per_page => 10, :page_index => 1)
@@ -1,3 +1,3 @@
1
1
  module BaiduWeb
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  end
data/lib/baidu_web.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
  $:.unshift(File.dirname(__FILE__))
3
3
 
4
+ require 'mechanize'
4
5
  require 'hpricot'
5
6
  require 'open-uri'
6
- #require 'iconv'
7
- #require 'cgi'
7
+ require 'cgi'
8
8
  require "baidu_web/version"
9
9
  require "baidu_web/record"
10
10
  require "baidu_web/extension_key"
@@ -21,7 +21,7 @@ module BaiduWeb
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(@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]
@@ -56,7 +56,7 @@ module BaiduWeb
56
56
  # end
57
57
  # }
58
58
 
59
- return result if doc.blank?
59
+ return result if doc.nil?
60
60
 
61
61
  result[:record_arr] = extract_item(doc, item_index)
62
62
  result[:ext_key_arr] = extract_extension_key(doc)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baidu_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: