Jump to content

GeekTool Scripts using Ruby (10.6.8)?


1 post in this topic

Recommended Posts

Sorry if this is in the wrong place, it's my first post.

 

 

I was wondering if there is a possible way to make a geeklet able to scrape my monthly aggregate data meter, since Comcast has a 250GB cap I'd like to avoid going over it. (Really close this month)

 

According the the FAQ Comcast has about its bandwith cap, only 1% of users go over 250GB and that general users use roughly 4-6GB a month.

 

I call bull on that one, especially in this day and age. Even netflix uses roughly 0.7GB per hour of video, over 1GB if its in HD, not to mention data syncing services and steaming youtube/vimeo/soundcloud then theres misc file downloads, program trials, etc etc

 

But yeah I only have 7GB left til i hit my cap haha.

 

 

 

There is a Ruby script for it

 

http://wonko.com/post/ruby-script-to-displ...cast-data-usage

 

#!/usr/bin/env ruby

require 'rubygems'
require 'mechanize'

URL_LOGIN = 'https://login.comcast.net/login?continue=https://login.comcast.net/account'
URL_USERS = 'https://customer.comcast.com/Secure/Users.aspx'

abort "Usage: #{$0} <username> <password>" unless ARGV.length == 2

agent = Mechanize.new

agent.follow_meta_refresh = true
agent.redirect_ok = true
agent.user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6'

login_page = agent.get(URL_LOGIN)

login_form = login_page.form_with(:name => 'signin')
login_form.user = ARGV[0]
login_form.passwd = ARGV[1]

redirect_page = agent.submit(login_form)
redirect_form = redirect_page.form_with(:name => 'redir')

abort 'Error: Login failed' unless redirect_form

account_page = agent.submit(redirect_form, redirect_form.buttons.first)

users_page = agent.get(URL_USERS)
usage_text = users_page.search("div[@class='usage-graph-legend']").first.content

puts usage_text.strip

 

Here is the script

 

 

however I think there's more that needs to be done for that to show up, seeing as the script shows no output through geektool (in text)

Link to comment
Share on other sites

 Share

×
×
  • Create New...