Class: MlbHeadlines::Scraper
- Inherits:
-
Object
- Object
- MlbHeadlines::Scraper
- Defined in:
- lib/mlb_headlines/scraper.rb
Instance Attribute Summary collapse
-
#article ⇒ Object
Returns the value of attribute article.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Attribute Details
#article ⇒ Object
Returns the value of attribute article.
3 4 5 |
# File 'lib/mlb_headlines/scraper.rb', line 3 def article @article end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/mlb_headlines/scraper.rb', line 3 def title @title end |
Class Method Details
.scrape ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/mlb_headlines/scraper.rb', line 6 def self.scrape @doc = Nokogiri::HTML(open('http://www.cbssports.com/fantasy/baseball/players/news/all/both/')) @doc.css("ul#playerNewsContent li").map do |headline| title = headline.css("h4").text article = headline.css(".latest-updates p").map(&:text).join(" ") MlbHeadlines::Headline.new(title, article) end end |