baidu 1.2.5 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/baidu.rb +7 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b31dd8b631dbab567991e53f1a6b54a4d7fd9ce
4
- data.tar.gz: 2bdc0cd46017d2b02176fae221895b1d0e7db9bc
3
+ metadata.gz: fff1b4daafda243caeb45c9a0f61328fcf99339e
4
+ data.tar.gz: e01864f549e755132840dfb46ed48199c9d93f42
5
5
  SHA512:
6
- metadata.gz: cf1c086b498c805a1dd497fea7d2467e036c1b5d66f8a773e992a819735447d90244661947dd5f9b081a2a272057c69df14759566d25e2d70798c2d27cc27c3e
7
- data.tar.gz: 596c6098e190ff0e5835bc1f2daff641123805ee2894bc6d9f431d110b587fbb6e17d96822d56147822757c998ef393b702555ff30d1bae48b6c1e7d4de1ad61
6
+ metadata.gz: 6bcd416445c07cabad3e68dd485b250af63a0d95dec654aacace1591bb02e9c0d51207cdfb810f05eac265d85407bbfb7a35a736ff3059251fa423c612777667
7
+ data.tar.gz: 4ee5fdcdcc2adc5d587521950d72afde0f5082ed0d90d01897e3dcf2e8886a4008a1eefeaef7d8ab466a764b92d2d90da9fca6f585cd409d7b78657e10dd015c
data/lib/baidu.rb CHANGED
@@ -75,7 +75,8 @@ class QihooResult < SearchResult
75
75
  def ranks
76
76
  return @ranks unless @ranks.nil?
77
77
  @ranks = Hash.new
78
- id = (@pagenumber - 1) * 10
78
+ # id = (@pagenumber - 1) * 10
79
+ id = 0
79
80
  @page.search('//li[@class="res-list"]').each do |li|
80
81
  a = li.search("h3/a").first
81
82
  url = li.search("cite")
@@ -85,7 +86,7 @@ class QihooResult < SearchResult
85
86
  href = a['href']
86
87
  url = url.first.text
87
88
  host = Addressable::URI.parse(URI.encode("http://#{url}")).host
88
- @ranks[id.to_s] = {'href'=>"http://so.com#{href}",'text'=>text,'host'=>host}
89
+ @ranks[id.to_s] = {'href'=>a['href'],'text'=>text,'host'=>host}
89
90
  end
90
91
  @ranks
91
92
  end
@@ -93,7 +94,7 @@ class QihooResult < SearchResult
93
94
  id = 0
94
95
  result = []
95
96
  @page.search("//ul[@id='djbox']/li").each do |li|
96
- id+=1
97
+ id += 1
97
98
  title = li.search("a").first.text
98
99
  href = li.search("cite").first.text.downcase
99
100
  host = Addressable::URI.parse(URI.encode(href)).host
@@ -126,7 +127,7 @@ class QihooResult < SearchResult
126
127
  next_href = next_href.first['href']
127
128
  next_href = URI.join(@baseuri,next_href).to_s
128
129
  # next_href = URI.join("http://#{@host}",next_href).to_s
129
- next_page = HTTParty.get(next_href).page
130
+ next_page = HTTParty.get(next_href).next
130
131
  return QihooResult.new(next_page,next_href,@pagenumber+1)
131
132
  #@page = MbaiduResult.new(Mechanize.new.click(@page.link_with(:text=>/下一页/))) unless @page.link_with(:text=>/下一页/).nil?
132
133
  end
@@ -186,7 +187,7 @@ class MbaiduResult < SearchResult
186
187
  id = nil
187
188
  else
188
189
  id = id.first.first.to_i
189
- id = (@pagenumber-1)*10+id
190
+ # id = (@pagenumber-1)*10+id
190
191
  end
191
192
  =begin
192
193
  result.children.each do |elem|
@@ -372,7 +373,7 @@ class BaiduResult < SearchResult
372
373
  @ranks[id] = Hash.new
373
374
  url = table.search("[@class=\"g\"]").first
374
375
  url = url.text unless url.nil?
375
- a = table.search("a").first
376
+ a = table.search("h3").first
376
377
  next if a.nil?
377
378
  @ranks[id]['text'] = a.text
378
379
  @ranks[id]['href'] = url #a.first['href'].sub('http://www.baidu.com/link?url=','').strip
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.2.5
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - seoaqua