Sha256: 3298a926f50ca515c1adc7af4f869443eff86d33bbbe8c20783f43248d8a8845

Contents?: true

Size: 509 Bytes

Versions: 1

Compression:

Stored size: 509 Bytes

Contents

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))
    rescue
      @doc = Nokogiri::HTML::Document.parse('No data')
    end

    def selector_content css
      @doc.css(css).collect{|a| a.content }.inject(:+)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scrapzirra-0.0.2 lib/scrapzirra/scrap.rb