Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
scrape total lives saved count from martin-baker web.
# coding: utf-8
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'date'
html = Nokogiri::HTML(open('http://www.martin-baker.com/'))
uls = html.xpath('//*[@id="totalLivesSaved"]')
count = 0
uls[0].xpath('li').each do |li|
numstr = li["class"].gsub(/number-/,'')
count = count * 10 + numstr.to_i
end
date = Date.today.strftime("%Y/%m/%d")
puts "#{date}\t#{count}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment