class TextSearch::Web

Public Class Methods

new(url, words=[]) click to toggle source
# File lib/text_search/web.rb, line 9
def initialize(url, words=[])
        @url = url
        @words = words
        fetchtext
end

Public Instance Methods

words() click to toggle source
# File lib/text_search/web.rb, line 19
def words
        TextSearch::Base.words(@text.downcase)
end

Private Instance Methods

fetchtext() click to toggle source
# File lib/text_search/web.rb, line 23
      def fetchtext
  @url = "http://#{@url}" if (!URI.parse(URI.encode(@url)).scheme)
  @text = ""
  begin                                                            
    html = Nokogiri::HTML(open(URI.parse(URI.encode(@url)), :allow_redirections => :safe))         
    html.css('script').remove    
    @text =  html.at('html').inner_text                              
  rescue Exception => e                                        
    return @text                                        
  end     
  return @text
end