baidu 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/baidu.rb +6 -4
  2. metadata +1 -1
@@ -80,13 +80,15 @@ class QihooResult < SearchResult
80
80
  href = a['href']
81
81
  url = url.first.text
82
82
  host = Addressable::URI.parse(URI.encode("http://#{url}")).host
83
- @ranks[id] = {'href'=>"http://so.com#{href}",'text'=>text,'host'=>host}
83
+ @ranks[id.to_s] = {'href'=>"http://so.com#{href}",'text'=>text,'host'=>host}
84
84
  end
85
85
  @ranks
86
86
  end
87
87
  #下一页
88
88
  def next
89
- next_href = @body.xpath('//a[@id="snext"]').first['href']
89
+ next_href = @body.xpath('//a[@id="snext"]')
90
+ return false if next_href.empty?
91
+ next_href = next_href.first['href']
90
92
  next_href = URI.join(@baseuri,next_href).to_s
91
93
  # next_href = URI.join("http://#{@host}",next_href).to_s
92
94
  next_body = HTTParty.get(next_href).body
@@ -139,7 +141,7 @@ class MbaiduResult < SearchResult
139
141
  href,text,host,is_mobile = '','','',false
140
142
  a = result.search("a").first
141
143
  is_mobile = true unless a.search("img").empty?
142
- host = result.search('span[@class="site"]').first.text
144
+ host = result.search('[@class="site"]').first.text
143
145
  href = a['href']
144
146
  text = a.text
145
147
  id = href.scan(/&order=(\d+)&/)
@@ -169,7 +171,7 @@ class MbaiduResult < SearchResult
169
171
  end
170
172
  =end
171
173
 
172
- @ranks[id] = {'href'=>href,'text'=>text,'is_mobile'=>is_mobile,'host'=>host.sub(/\u00A0/,'')}
174
+ @ranks[id.to_s] = {'href'=>href,'text'=>text,'is_mobile'=>is_mobile,'host'=>host.sub(/\u00A0/,'')}
173
175
  end
174
176
  @ranks
175
177
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baidu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: