Skip to content

Instantly share code, notes, and snippets.

@r4um
Created August 21, 2012 09:57
Show Gist options
  • Save r4um/3414116 to your computer and use it in GitHub Desktop.
Save r4um/3414116 to your computer and use it in GitHub Desktop.
Display Airtel broadband usage.
#!/usr/bin/env ruby
# Display airtel broadband usage. Output format is
# airtel_id/quota GB/used GB/days_left
require 'rubygems'
require 'nokogiri'
require 'open-uri'
page = Nokogiri::HTML(open("http://122.160.230.125:8080/gbod/gb_on_demand.do", 'User-Agent' => 'curl/7.26.0', 'Accept' => "*/*"))
info = []
page.xpath('//ul')[0].children.each do |n|
if n.text =~ /[\w\s]+:\s*\u00a0*(.*)/
info.push $1
end
end
puts info.join("/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment