class NPRCLIApp::Story

Attributes

category[RW]
teaser[RW]
title[RW]

Public Class Methods

scrape_top_story() click to toggle source
# File lib/npr_cli_app/story.rb, line 4
def self.scrape_top_story
  doc = Nokogiri::HTML(open("https://www.npr.org"))
  top_story = NPRCLIApp::Story.new
  top_story.title = doc.search('h3.title').first.text
  top_story.category = doc.search('h2.slug a').first.text.strip
  top_story.link = doc.search('div.story-text a')[1].attr('href')
  top_story.teaser = doc.search('p.teaser').text.gsub("\"", "")
  top_story

end