Skip to content

Instantly share code, notes, and snippets.

@symm
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save symm/ddafa23f74a07b38135e to your computer and use it in GitHub Desktop.
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
#!/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
@symm
Copy link
Author

symm commented Jul 25, 2015

I couldn't find an API from EE for fetching the info, can scrape from the status page however.

Plan to use with dashing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment