Last active
August 29, 2015 14:25
-
-
Save symm/ddafa23f74a07b38135e to your computer and use it in GitHub Desktop.
A little script for showing the remaining data allowance on EE data SIM
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 | |
require 'mechanize' | |
require 'filecache' | |
cache = FileCache.new("data-usage", "/tmp", 60 * 30, 3) | |
unless cache.get('usage').nil? | |
puts cache.get('usage') | |
exit 0 | |
end | |
website = "http://add-on.ee.co.uk/status" | |
mechanize = Mechanize.new | |
page = mechanize.get(website) | |
data = page.at('#data-usage').at('dl').at('.data-left-value').text.strip | |
expiry = page.at('#data-usage').at('dl').at('.ends-in-value').text.strip | |
remaining, allowance = data.split(' / ') | |
expiry = expiry.gsub("\n",'') | |
expiry = expiry.gsub(" ",' ') | |
output = remaining + '/' + allowance | |
cache.set('usage', output) | |
puts output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I couldn't find an API from EE for fetching the info, can scrape from the status page however.
Plan to use with dashing