Skip to content

Instantly share code, notes, and snippets.

@rbpd5015
Created January 31, 2015 23:43
Show Gist options
  • Save rbpd5015/af981a15080e837c55f3 to your computer and use it in GitHub Desktop.
Save rbpd5015/af981a15080e837c55f3 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
f = File.open("NBAtest.html")
doc = Nokogiri::HTML(f, nil, "UTF-8")
doc.gsub("½", ".5")
gameid = doc.xpath('.//*[@itemtype="http://schema.org/SportsEvent"]/@id').collect {|node| node.text.strip}
startdate = doc.xpath('.//*[@itemprop="startdate"]/@content').collect {|node| node.text.strip}
name = doc.xpath('.//*[@itemprop="name"]/@content').collect {|node| node.text.strip}
url = doc.xpath('.//*[@itemprop="url"]/@content').collect {|node| node.text.strip}
address = doc.xpath('.//*[@itemprop="address"]/@content').collect {|node| node.text.strip}
rotation = doc.xpath('.//*[@class="el-div eventLine-rotation"]/*[@class="eventLine-book-value"]').collect {|node| node.text.strip}
time = doc.xpath('.//*[@class="el-div eventLine-time"]').collect {|node| node.text.strip}
teams = doc.xpath('.//*[@class="el-div eventLine-team"]/*[@class="eventLine-value"]').collect {|node| node.text.strip}
tv = doc.xpath('.//*[@class="el-div eventLine-tvStation"]/*[@class="eventLine-book-value"]').collect {|node| node.text.strip}
opener = doc.xpath('.//*[@class="el-div eventLine-opener"]/*[@class="eventLine-book-value"]').collect {|node| node.text.strip}
# puts gameid
# puts startdate
# puts name
# puts url
# puts address
# puts rotation
# puts time
# puts teams
# puts tv
# puts opener
puts doc
#puts doc
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment