Sha256: fd1b0af3bdf3cda9ee81bb892ea9b9df9c255705912ebcb4376a0f0cfbed5d20

Contents?: true

Size: 563 Bytes

Versions: 2

Compression:

Stored size: 563 Bytes

Contents

require 'pry'
class WikiOnThisDay::Scraper::Homepage < WikiOnThisDay::Scraper
  attr_accessor :snippets

  def initialize
    super('https://en.wikipedia.org/wiki/Main_Page')
    @snippets = Array.new
    self.html_doc.search('div#mp-otd div#mp-otd-img + ul li').each do |event|
      @snippets << WikiOnThisDay::Snippet.new(year: event.css('a').first.text, text: event.children.text.split(/ – /)[1], link_url: 'https://en.wikipedia.org' + event.css('b a')[0]["href"])
    end
  end

  def summarize
    self.snippets.each { |snippet| snippet.print }
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wiki_on_this_day-0.2.1 lib/wiki_on_this_day/homepage.rb
wiki_on_this_day-0.2.0 lib/wiki_on_this_day/homepage.rb