Skip to content

Instantly share code, notes, and snippets.

@jimmybaker
Created March 24, 2009 22:18
Show Gist options
  • Save jimmybaker/84398 to your computer and use it in GitHub Desktop.
Save jimmybaker/84398 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'open-uri'
require 'scrapi'
require 'hpricot'
# url = "http://www.edgewise-media.com/sonmindv60mi.html"
# css_selector = "html>body>table:nth-of-type(2) tr>td:nth-of-type(3)>table:nth-of-type(2) tr>td>form>font>table tr:nth-of-type(2)>td:nth-of-type(2)>font:nth-of-type(1)"
url = "http://www.tapestockonline.com/son60minprem.html"
css_selector = "html>body>table:nth-of-type(2) tr>td:nth-of-type(3)>table tr>td>form>table tr:nth-of-type(5)>td>table tr>td>table tr:nth-of-type(2)>td>table tr>td:nth-of-type(2)"
#
# doc = Hpricot(open(url))
scraper = Scraper.define do
process css_selector, :price=>:text
end
result = scraper.scrape(URI.parse(url))
puts result.price[/[\d\.]+/]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment