Class: TldrNews::Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/tldr_news/scraper.rb

Instance Method Summary collapse

Constructor Details

#initializeScraper

Returns a new instance of Scraper.



4
5
# File 'lib/tldr_news/scraper.rb', line 4

def initialize
end

Instance Method Details

#get_pageObject



7
8
9
# File 'lib/tldr_news/scraper.rb', line 7

def get_page
  Nokogiri::HTML(open('https://tldrworldnews.com/'))
end

#make_articlesObject



15
16
17
18
19
# File 'lib/tldr_news/scraper.rb', line 15

def make_articles
  scrape_articles.each do |listing|
    TldrNews::Article.new_from_html(listing)
  end
end

#scrape_articlesObject



11
12
13
# File 'lib/tldr_news/scraper.rb', line 11

def scrape_articles
  self.get_page.css('div.listing')
end