class AtpRankings::Scraper
Public Instance Methods
create_athletes()
click to toggle source
# File lib/atp_rankings/scraper.rb, line 10 def create_athletes i = 1 while i < 26 do scrape_athletes_index.each do |a| athlete = AtpRankings::Athlete.new athlete.rank = a.search("tr[#{i}] .rank-cell").text.strip athlete.name = a.search("tr[#{i}] .player-cell").text.strip athlete.age = a.search("tr[#{i}] .age-cell").text.strip athlete.points = a.search("tr[#{i}] .points-cell").text.strip athlete.tourn_played = a.search("tr[#{i}] .tourn-cell").text.strip athlete.url = "http://www.atpworldtour.com" + a.search("tr[#{i}] .player-cell a").attr("href").text i += 1 end end end
get_page()
click to toggle source
# File lib/atp_rankings/scraper.rb, line 2 def get_page Nokogiri::HTML(open("http://www.atpworldtour.com/en/rankings/singles-race-to-london")) end
scrape_athletes_index()
click to toggle source
# File lib/atp_rankings/scraper.rb, line 6 def scrape_athletes_index self.get_page.search("#singlesRanking") end