class Parser::Exercise
Public Class Methods
new(url, options)
click to toggle source
Calls superclass method
Parser::Base::new
# File lib/fly_parser/sources/exercise.rb, line 4 def initialize(url, options) @delay = 5 super end
Public Instance Methods
next_page()
click to toggle source
Calls superclass method
Parser::Base#next_page
# File lib/fly_parser/sources/exercise.rb, line 8 def next_page super(:class => 'nextpostslink') end
parse_page()
click to toggle source
# File lib/fly_parser/sources/exercise.rb, line 12 def parse_page #until next page exists links = @source.links_with(:class => 'readmore') links.map do |link| page = link.click article = page.search('.post') title = article.search('.title').text() wrapper = article.search('.entry') wrapper.search('a').remove_attr('href') poster_image = wrapper.search('img').first.attributes['src'].value start_element = wrapper.at('p:nth-child(2)') end_element = wrapper.xpath("//comment()[. = ' adman_adcode_after ']").first next if start_element.next.nil? content = collect_between(start_element,end_element).map(&:to_s).join next if content.nil? {title: title, content: content, poster_image: poster_image} end.compact end