Class: NewsReader::Scraper
- Inherits:
-
Object
- Object
- NewsReader::Scraper
- Defined in:
- lib/news_reader/scraper.rb
Overview
require ‘pry’
Class Method Summary collapse
Class Method Details
.fetch_articles ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/news_reader/scraper.rb', line 6 def self.fetch_articles doc = Nokogiri::HTML(open("http://www.loremipsum.biz/blog")) doc.css(".blog-post").map do |post| { title: post.css("h2").text, date: post.css(".post-details").text.split("|")[0].split(":")[1].strip, url: post.css("h2 a").attribute("href").value, text: post.css("p").text } end end |