Class: Parser::Fitness
Instance Method Summary collapse
Methods inherited from Base
#collect_between, #copyright, #initialize, #parse_all
Constructor Details
This class inherits a constructor from Parser::Base
Instance Method Details
#next_page ⇒ Object
5 6 7 |
# File 'lib/fly_parser/sources/fitness.rb', line 5 def next_page super(:id => 'next_page') end |
#parse_page ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fly_parser/sources/fitness.rb', line 9 def parse_page # until next page exists links = @source.links_with(:class => 'article-headine__link') links.map do |link| href = link.href page = link.click article = page.search('div[itemscope]') title = article.search('.article-name').text() # images stuff wrapper = article.search('.article-text__wrapper') # if poster_image doesn't exists, it looks like strange promo ads, so skip it next if wrapper.search('.article_image__pic').first.nil? poster_image = @copyright[:url] + wrapper.search('.article_image__pic').first.attributes['src'].value wrapper.search('.article_image__pic').first.remove() wrapper.search('.article_image__pic') images = wrapper.search('.article_image__pic') # expand path for images images.map {|image| image.attributes['src'].value = image.attributes['src'].value.prepend(@copyright[:url]); image } # remove ad wrapper.search('.po_theme').remove() wrapper.search('a').remove_attr('href') {title: title, content: wrapper.inner_html, poster_image: poster_image} end.compact end |