baidu 1.2.5 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/baidu.rb +7 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fff1b4daafda243caeb45c9a0f61328fcf99339e
|
4
|
+
data.tar.gz: e01864f549e755132840dfb46ed48199c9d93f42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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'=>
|
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).
|
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("
|
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
|