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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/baidu.rb +54 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0768a46d047958a319217e93287ae6447e2096f
4
- data.tar.gz: 60c1c2ddb45e5f19f399563c7be4a2700dd68b46
3
+ metadata.gz: e365ab20a00b69abc98208634364d75b9e353fce
4
+ data.tar.gz: 60912cea646f94dfdf4a9df87ba697507cb890ae
5
5
  SHA512:
6
- metadata.gz: 277b7e0ad48bbfd062849c32dc12f1d6aa7e53b1bc05bf903cebf7e8471b4301fddcf70e77b10fe01103a3e8530d00504eb466d8d9ca0165747c9e6d548a7535
7
- data.tar.gz: f978c496e06b9b80361658e9450c91d32c68fcf899d8a62f83a7d76697f17548f0928524201a3d3e72b8b6f697dda9ab9a1d16a219b58322be1b29b72fba9ee8
6
+ metadata.gz: 9079605ab35f9bad3f4a6ea5bc1a4f10857f577bae373d0f55e9f408ef8b03d4951a908829e96f037ef1097f27ef386a1b163f650597bc0514063ea674af506c
7
+ data.tar.gz: df97b73c25150cc0bfef6d202db5e73d562e3bd5d3fdd3b8eb93b52f2f934e33353df88418f7fada0566ed5f123e96d98688ef175cb4a0e6be208e7a0928c347
@@ -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
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.7
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - seoaqua