class NtrResults::Scraper

Attributes

date[RW]
location[RW]
name[RW]
url[RW]
winner[RW]

Public Class Methods

all() click to toggle source
# File lib/ntr_results/scraper.rb, line 4
def self.all
  # scrape nationalteamroping.com
  self.scrape_events
end
scrape_events() click to toggle source
# File lib/ntr_results/scraper.rb, line 9
def self.scrape_events
  events = []

  events << self.scrape_ntr1
  events << self.scrape_ntr2
  events << self.scrape_ntr3
  # events << self.scrape_ntr

  events
end
scrape_ntr1() click to toggle source

def self.scrape_ntr

doc = Nokogiri::HTML(open("http://nationalteamroping.com/articles.sec-26-1-results.html"))
event = self.new
event.name = doc.css(".title-txt h1 a").collect{|e| e.text}
# event.name = doc.css(".title-txt h1 a").collect{ |e| "#{e}"}
# event.name = doc.css(".title-txt h1 a").collect.to_s{ |e| "#{e}"}
event

end

# File lib/ntr_results/scraper.rb, line 32
def self.scrape_ntr1
  doc = Nokogiri::HTML(open("http://nationalteamroping.com/article-812-rancho-rio-qualifier.html"))

  event = self.new
  event.name = doc.search("#article-812 p")[0].text
  event.date  = doc.search("#article-812 p")[1].text
  event.location = doc.search("#article-812 p")[2].text
  event.winner = doc.search("#article-812 p")[10].text  # => "1st in Ave - 33.62 on 4, Sam Scott & John Miller  $1350"

  event
end
scrape_ntr2() click to toggle source
# File lib/ntr_results/scraper.rb, line 44
def self.scrape_ntr2
  doc = Nokogiri::HTML(open("http://nationalteamroping.com/article-815-tgif-4_7_17.html"))

  event = self.new
  event.name = doc.search("#article-815 p")[0].text
  event.date  = doc.search("#article-815 p")[1].text
  event.location = doc.search("#article-815 p")[2].text
  event.winner = doc.search("#article-815 p")[7].text  # => "1st in Ave - 40.31 on 4, Bruce Northrop & Richard Mayfield  $1840"

  event
end
scrape_ntr3() click to toggle source
# File lib/ntr_results/scraper.rb, line 56
def self.scrape_ntr3
  doc = Nokogiri::HTML(open("http://nationalteamroping.com/article-816-%25245000-sat.html"))

  event = self.new
  event.name = doc.search("#article-816 p")[0].text
  event.date  = doc.search("#article-816 p")[1].text
  event.location = doc.search("#article-816 p")[2].text
  event.winner = doc.search("#article-816 p")[7].text  # =>  "1st in Ave - 38.35 on 4, Jerry Turk & Pat Danehey  $5000"

  event
end