lib/gsearch-parser.rb in gsearch-parser-0.1.4 vs lib/gsearch-parser.rb in gsearch-parser-0.2.0

- old
+ new

@@ -3,21 +3,21 @@ require 'nokogiri' module GSearchParser def GSearchParser.webSearch(query) - GoogleSearch.new(query) + GoogleWebSearch.new(query) end end ################################################### # # -# GoogleSearch Class # +# GoogleWebSearch Class # # # ################################################### -class GoogleSearch +class GoogleWebSearch attr_accessor :results # Class initializer def initialize(query) # Initialize array @@ -38,9 +38,14 @@ # the content to be nil, so check for this content = result.css('span.st').first.nil? ? '' : result.css('span.st').first.inner_html # Extract the URI uri = result.css('cite').first.inner_html + + # Ignore YouTube videos for websearch + unless uri.index('www.youtube.com').nil? + next + end # Create a new Result object and append to the array @results << Result.new(title, content, uri) end end