Sha256: 5c33ae24eada4aee81a4dd519b639e068fb6bf864e3d4ac7475d6cdf9153c0fb
Contents?: true
Size: 966 Bytes
Versions: 1
Compression:
Stored size: 966 Bytes
Contents
## - module: Feed::Custom ## config: ## url: 'http://www.fraction.jp/' ## extract_xpath: ## capture: '//div' ## split: '//div[@class="test"]' ## description: '//div' ## link: '//li[2]' ## title: '//p' ## apply_template_after_extracted: ## content_encoded: '<div><%= title %></div>' ## require 'yapra/plugin/mechanize_base' module Yapra::Plugin::Feed class Custom < Yapra::Plugin::MechanizeBase def run(data) page = agent.get(config['url']) root = page.root xconfig = config['extract_xpath'] if xconfig['capture'] root = root.at(xconfig['capture']) end split = xconfig['split'] xconfig.delete('capture') xconfig.delete('split') root.search(split).each do |element| item = RSS::RDF::Item.new extract_attribute_from element, item data << item end data end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yapra-0.1.0 | lib-plugins/yapra/plugin/feed/custom.rb |