Sha256: d7eef8cab940f6c6eb25827be2830b7f7451d3ed710246807f205618e5daed87
Contents?: true
Size: 802 Bytes
Versions: 1
Compression:
Stored size: 802 Bytes
Contents
module LoomioScraper class Scraper def initialize(url) @dom = Scraper.html_loader(url) @attributes = [] end def self.html_loader(url) # return Nokogiri::HTML(File.open('index.html').read) gem_path = LoomioScraper::home_dir script_path = gem_path + '/lib/LoomioScraper/script.js' file_path = gem_path + '/index.html' dom = html = nil pid ||= Process.spawn('phantomjs', script_path, url, file_path) Process.waitpid(pid) html ||= File.open(file_path).read File.delete(file_path) dom ||= Nokogiri::HTML(html) end def to_hash @attributes.reduce({}) { |hash, attr| hash[attr.to_sym] = self.send(attr.to_sym); hash } end def attributes @attributes end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
LoomioScraper-0.1.1 | lib/LoomioScraper/helper.rb |