module Scrapzirra class Scrap attr_accessor :url def initialize url, options = {} @url = url @doc = Nokogiri::HTML(options[:doc]) if options[:doc] end def doc @doc || load_doc end def load_doc require 'nokogiri' require 'open-uri' @doc = Nokogiri::HTML(open(@url).read) @doc.encoding = 'utf-8' @doc rescue @doc = Nokogiri::HTML::Document.parse('No data') end def selector_content css doc.css(css).collect{|a| a.inner_html }.inject(:+) end end end