I'm trying to get Nokogiri to scrape ESPN's site for Jeremy Lin's last game stats, however, the CSS text method is giving me a string without any spaces between the stats.
The string that scraper.get_last_game_stats.text
is returning is:
"Sat 11/16vsDENW 122-111326-11.5450-2.0004-6.66747113116Wed 11/13@ PHIL 117-1234910-19.5269-15.6005-6.833512005834Sat 11/9vsLACL 94-107263-7.4290-0.0000-0.0001701156"
I am trying to put spaces between each of the stats however, even when I loop through the main object, putting spaces or dashes between iterations, I can't split the numbers for steals, blocks, points, turnovers and everything else:
class PlayerScraper
attr_accessor :player_data, :name
def initialize(url)
@player_data = Nokogiri::HTML(open(url))
end
def get_last_game_stats
@last_game_stats = @player_data.css('tr[class^="oddrow team-46"]')
end
end
jlin_url = "http://espn.go.com/nba/player/_/id/4299/jeremy-lin"
scraper = PlayerScraper.new(jlin_url)
scraper.get_last_game_stats.text
Can someone show me a better way of doing this?