Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Ruby program to scrape specific information of a web page
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we’re interested in...
url = ''
doc = Nokogiri::HTML(open(url)) #do |config|
doc.at_css("ul#counter li.ended").text
# config.noerror
# Search for nodes by css
doc.css('h2.control_title').each do |link|
puts "\n"
puts "Deal Title: " +link.content.to_s.strip
puts "\n"
doc.css('.merchant_info.control.clearfix .merchant_name').each do |link|
puts "Merchant name: " +link.content.to_s.strip
puts "\n"
doc.css('#price_tag_inner #amount').each do |link|
puts "Price: " +link.content
puts "\n"
doc.css('.clearfix #deal_discount').each do |link|
puts link.content.to_s.strip.gsub(/ /,'')
puts "\n"
doc.css('td.left span.number').each do |link|
puts "Deals bought: " +link.content
puts "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.