baidu 1.1.7 → 1.1.9
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.
- checksums.yaml +4 -4
- data/lib/baidu.rb +54 -1
- 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: e365ab20a00b69abc98208634364d75b9e353fce
|
|
4
|
+
data.tar.gz: 60912cea646f94dfdf4a9df87ba697507cb890ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9079605ab35f9bad3f4a6ea5bc1a4f10857f577bae373d0f55e9f408ef8b03d4951a908829e96f037ef1097f27ef386a1b163f650597bc0514063ea674af506c
|
|
7
|
+
data.tar.gz: df97b73c25150cc0bfef6d202db5e73d562e3bd5d3fdd3b8eb93b52f2f934e33353df88418f7fada0566ed5f123e96d98688ef175cb4a0e6be208e7a0928c347
|
data/lib/baidu.rb
CHANGED
|
@@ -83,6 +83,36 @@ class QihooResult < SearchResult
|
|
|
83
83
|
end
|
|
84
84
|
@ranks
|
|
85
85
|
end
|
|
86
|
+
def ads_top
|
|
87
|
+
id = 0
|
|
88
|
+
result = []
|
|
89
|
+
@body.search("//ul[@id='djbox']/li").each do |li|
|
|
90
|
+
id+=1
|
|
91
|
+
title = li.search("a").first.text
|
|
92
|
+
href = li.search("cite").first.text.downcase
|
|
93
|
+
host = Addressable::URI.parse(URI.encode(href)).host
|
|
94
|
+
result[id] = {'title'=>title,'href'=>href,'host'=>host}
|
|
95
|
+
end
|
|
96
|
+
result
|
|
97
|
+
end
|
|
98
|
+
def ads_bottom
|
|
99
|
+
[]
|
|
100
|
+
end
|
|
101
|
+
def ads_right
|
|
102
|
+
id = 0
|
|
103
|
+
result = []
|
|
104
|
+
@body.search("//ul[@id='rightbox']/li").each do |li|
|
|
105
|
+
id += 1
|
|
106
|
+
title = li.search("a").first.text
|
|
107
|
+
href = li.search("cite").first.text.downcase
|
|
108
|
+
host = Addressable::URI.parse(URI.encode(href)).host
|
|
109
|
+
result[id] = {'title'=>title,'href'=>href,'host'=>host}
|
|
110
|
+
end
|
|
111
|
+
result
|
|
112
|
+
end
|
|
113
|
+
def related_keywords
|
|
114
|
+
[]
|
|
115
|
+
end
|
|
86
116
|
#下一页
|
|
87
117
|
def next
|
|
88
118
|
next_href = @body.xpath('//a[@id="snext"]')
|
|
@@ -176,6 +206,28 @@ class MbaiduResult < SearchResult
|
|
|
176
206
|
end
|
|
177
207
|
@ranks
|
|
178
208
|
end
|
|
209
|
+
def ads_top
|
|
210
|
+
id = 0
|
|
211
|
+
result = []
|
|
212
|
+
@body.search("div[@class='ec_wise_ad']/div").each do |div|
|
|
213
|
+
id += 1
|
|
214
|
+
href = div.search("span[@class='ec_site']").first.text
|
|
215
|
+
href = "http://#{href}"
|
|
216
|
+
title = div.search("a/text()").text.strip
|
|
217
|
+
host = Addressable::URI.parse(URI.encode(href)).host
|
|
218
|
+
result[id] = {'title'=>title,'href'=>href,'host'=>host}
|
|
219
|
+
end
|
|
220
|
+
result
|
|
221
|
+
end
|
|
222
|
+
def ads_right
|
|
223
|
+
[]
|
|
224
|
+
end
|
|
225
|
+
def ads_bottom
|
|
226
|
+
[]
|
|
227
|
+
end
|
|
228
|
+
def related_keywords
|
|
229
|
+
[]
|
|
230
|
+
end
|
|
179
231
|
=begin
|
|
180
232
|
#返回当前页中,符合host条件的结果
|
|
181
233
|
def ranks_for(specific_host)
|
|
@@ -417,4 +469,5 @@ class BaiduResult < SearchResult
|
|
|
417
469
|
@page.search('//div[@class="nors"]').empty?
|
|
418
470
|
end
|
|
419
471
|
|
|
420
|
-
end
|
|
472
|
+
end
|
|
473
|
+
puts Qihoo.new.query('深圳').related_keywords
|