Sha256: 90a7b2bf8a08696bb70d5493f1aaaa377be1abde7cd8e68fa4dd6b29e5de4cbe
Contents?: true
Size: 557 Bytes
Versions: 2
Compression:
Stored size: 557 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).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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
scrapzirra-0.0.6 | lib/scrapzirra/scrap.rb |
scrapzirra-0.0.5 | lib/scrapzirra/scrap.rb |