Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Duly stolen from a Python version by nicolasH/apple system I think one can see that Ruby can be quite concise if you need to
#!/usr/bin/env ruby
# encoding: UTF-8
# ----------------------------------------------------------------------------
require 'nokogiri'
require 'open-uri'
require 'colorize'
doc = Nokogiri.HTML(open(''))
y = n = 0
puts '# ----------------------------------------------------'.white
doc.xpath('//td').each do |link|
print link.content
print ' '
if link[:class] == 'online'
puts "#{link[:class]}".green
y += 1
puts "#{link[:class]}".red
n += 1
puts '# ----------------------------------------------------'.white
puts "#{y + n} total, #{y} online, #{n} offline".white

This comment has been minimized.

Copy link

commented Aug 30, 2014

Is it possible for this to be done in PHP?
Felipe C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.