Created
May 6, 2009 03:05
-
-
Save jschoolcraft/107336 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| R. Oswalt (Houston Astros) vs. S. Olsen (Washington Nationals) | |
| A. Reyes (Cleveland Indians) vs. B. Cecil (Toronto Blue Jays) | |
| T. Lincecum (San Francisco Giants) vs. S. Marshall (Chicago Cubs) | |
| K. Uehara (Baltimore Orioles) vs. M. Garza (Tampa Bay Rays) | |
| V. Padilla (Texas Rangers) vs. E. Bedard (Seattle Mariners) | |
| L. Hernandez (New York Mets) vs. K. Kawakami (Atlanta Braves) | |
| N. Blackburn (Minnesota Twins) vs. R. Porcello (Detroit Tigers) | |
| J. Beckett (Boston Red Sox) vs. J. Chamberlain (New York Yankees) | |
| J. Suppan (Milwaukee Brewers) vs. I. Snell (Pittsburgh Pirates) | |
| E. Volquez (Cincinnati Reds) vs. C. Volstad (Florida Marlins) | |
| G. Floyd (Chicago White Sox) vs. K. Davies (Kansas City Royals) | |
| B. Myers (Philadelphia Phillies) vs. A. Wainwright (St. Louis Cardinals) | |
| S. Loux (Los Angeles Angels) vs. D. Braden (Oakland Athletics) | |
| A. Cook (Colorado Rockies) vs. J. Geer (San Diego Padres) | |
| M. Scherzer (Arizona Diamondbacks) vs. J. Weaver (Los Angeles Dodgers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'hpricot' | |
| require 'open-uri' | |
| require 'pp' | |
| class Probable | |
| def initialize(url) | |
| @doc = Hpricot(open(url)) | |
| end | |
| def get_match_up(row) | |
| if row | |
| cells = row.search("td") | |
| away, home = cells.first.search("a") | |
| [away.inner_html,home.inner_html] | |
| end | |
| end | |
| def get_pitcher_stats(row) | |
| if row | |
| row.at("td").at("a").inner_html | |
| end | |
| end | |
| def print_matchups | |
| probables = @doc.search("/html/body/div/div/div[2]/div[2]/div/table") | |
| probables.search("tr.colhead").remove | |
| probables.search("tr").each_slice(3) do |rows| | |
| away,home = get_match_up(rows[0]) # rows.at(".stathead")) | |
| away_pitcher = get_pitcher_stats(rows[1]) # rows.at(".oddrow")) | |
| home_pitcher = get_pitcher_stats(rows[2]) # rows.at(".evenrow")) | |
| puts "#{away_pitcher} (#{away}) vs. #{home_pitcher} (#{home})" | |
| end | |
| end | |
| end | |
| @probable = Probable.new("http://sports.espn.go.com/mlb/probables") | |
| @probable.print_matchups |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment