class NewsReader::Scraper
require 'pry'
Public Class Methods
fetch_articles()
click to toggle source
# 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