class Scraper

Public Class Methods

new(path = self.path) click to toggle source
# File lib/scraper.rb, line 8
def initialize(path = self.path)
  @posts = []
  @path = path
  @page = Nokogiri::HTML(open(path))
end

Public Instance Methods

create_new_post() click to toggle source
# File lib/scraper.rb, line 27
def create_new_post
  @posts.each {|post| Post.new(post)}
end
gather_posts_from_scouts() click to toggle source
# File lib/scraper.rb, line 14
def gather_posts_from_scouts
  @page.css(".story-list-item").each_with_index do |post, index|
    @posts[index] = {
      :title => post.css(".story-deck h1 a span").last.text,
      :author => post.css(".story-deck .story-from").text,
      :time => post.css(".story-deck .time-stamp").text,
      :description => post.css(".story-deck p").text,
      :link => post.css(".story-deck .story-stuff a").attribute("href").value
    }
  return false if @posts.empty?
  end
end
path() click to toggle source
# File lib/scraper.rb, line 37
def path
  "http://www.scout.com/college/football/recruiting/news?type=stories&sortBy=Date&site=ScoutFootball.com"
end
run_scrape_on_scouts() click to toggle source
# File lib/scraper.rb, line 31
def run_scrape_on_scouts
  if !@page.nil? && gather_posts_from_scouts
    create_new_post
  end
end