youtubesearchresultscraper 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/lib/youtube/searchresultscraper.rb +8 -7
- data/lib/youtube/searchresultscraper.rb~ +11 -8
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -199,24 +199,25 @@ module Youtube #:nodoc:
|
|
199
199
|
end
|
200
200
|
|
201
201
|
def scrape_result_header
|
202
|
-
@search_result.search("div[@id='sectionHeader']
|
202
|
+
@search_result.search("div[@id='sectionHeader']").inner_html
|
203
203
|
end
|
204
204
|
|
205
205
|
def scrape_video_count
|
206
|
-
video_count = scrape_result_header
|
207
|
-
raise "no video count"
|
206
|
+
video_count = scrape_result_header
|
207
|
+
raise "no video count" unless video_count.sub!(/.+Results \d+-\d+ of( | about )([0-9,]+)/m , '\2')
|
208
|
+
video_count.gsub!(/,/, '')
|
208
209
|
video_count.to_i
|
209
210
|
end
|
210
211
|
|
211
212
|
def scrape_video_from
|
212
|
-
video_from = scrape_result_header
|
213
|
-
raise "no video from"
|
213
|
+
video_from = scrape_result_header
|
214
|
+
raise "no video from" unless video_from.sub!(/.+Results (\d+)/m, '\1')
|
214
215
|
video_from.to_i
|
215
216
|
end
|
216
217
|
|
217
218
|
def scrape_video_to
|
218
|
-
video_to = scrape_result_header
|
219
|
-
raise "no video to"
|
219
|
+
video_to = scrape_result_header
|
220
|
+
raise "no video to" unless video_to.sub!(/.+Results \d+-(\d+)/m, '\1')
|
220
221
|
video_to.to_i
|
221
222
|
end
|
222
223
|
|
@@ -116,9 +116,6 @@ module Youtube #:nodoc:
|
|
116
116
|
@video_count = scrape_video_count
|
117
117
|
@video_from = scrape_video_from
|
118
118
|
@video_to = scrape_video_to
|
119
|
-
raise "no video count" if @video_count == nil
|
120
|
-
raise "no video from" if @video_from == nil
|
121
|
-
raise "no video to" if @video_to == nil
|
122
119
|
|
123
120
|
raise "scraping error" if (is_no_result != @videos.empty?)
|
124
121
|
|
@@ -202,23 +199,29 @@ module Youtube #:nodoc:
|
|
202
199
|
end
|
203
200
|
|
204
201
|
def scrape_result_header
|
205
|
-
@search_result.search("div[@id='sectionHeader']/div
|
202
|
+
@search_result.search("div[@id='sectionHeader']/div").inner_html
|
206
203
|
end
|
207
204
|
|
208
205
|
def scrape_video_count
|
209
|
-
scrape_result_header.sub(/.+of *(\d+)/m , '\1')
|
206
|
+
video_count = scrape_result_header.sub(/.+of *(\d+)/m , '\1')
|
207
|
+
raise "no video count" if video_count.empty?
|
208
|
+
video_count.to_i
|
210
209
|
end
|
211
210
|
|
212
211
|
def scrape_video_from
|
213
|
-
scrape_result_header.sub(/Results *(\d+)-.+/m, '\1')
|
212
|
+
video_from = scrape_result_header.sub(/Results *(\d+)-.+/m, '\1')
|
213
|
+
raise "no video from" if video_from.empty?
|
214
|
+
video_from.to_i
|
214
215
|
end
|
215
216
|
|
216
217
|
def scrape_video_to
|
217
|
-
scrape_result_header.sub(/Results.+-(\d+) *of.+/m, '\1')
|
218
|
+
video_to = scrape_result_header.sub(/Results.+-(\d+) *of.+/m, '\1')
|
219
|
+
raise "no video to" if video_to.empty?
|
220
|
+
video_to.to_i
|
218
221
|
end
|
219
222
|
|
220
223
|
def is_no_result
|
221
|
-
@
|
224
|
+
@html.include?('No Videos found')
|
222
225
|
end
|
223
226
|
|
224
227
|
def check_video video
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: youtubesearchresultscraper
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-02-
|
6
|
+
version: 0.0.5
|
7
|
+
date: 2007-02-16 00:00:00 +09:00
|
8
8
|
summary: This gem provide function to scrape html of search result on youtube
|
9
9
|
require_paths:
|
10
10
|
- lib
|