Created
August 21, 2012 09:57
-
-
Save r4um/3414116 to your computer and use it in GitHub Desktop.
Display Airtel broadband usage.
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
#!/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