Created
August 31, 2009 23:17
-
-
Save markmcdonald51/178770 to your computer and use it in GitHub Desktop.
This file contains 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' | |
gem 'scrapi' | |
require 'scrapi' | |
# Parse bens bargains! | |
URL = 'http://bensbargains.net/' | |
scraper = Scraper.define do | |
array :posts | |
process '.newsText', :posts => Scraper.define { | |
process '.newsTitle', :deal => :text | |
process 'b', :price => :text | |
process "a[rel='nofollow']", :link => '@href' | |
result :price, :deal, :link | |
} | |
result :posts | |
end | |
uri = URI.parse(URL) | |
scraper.scrape(uri).each do |product| | |
puts "deal => #{product.deal}" | |
puts "price => #{product.price}" | |
puts "deal => #{URL + product.link}" | |
puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment