Geekzone: technology news, blogs, forums
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.

26 posts


# 58728 17-Mar-2010 23:07
Send private message

Wrote this a couple weeks ago and figured some here might be interested. It's a Python script that connects to the Telecom broadband usage meter website and reads your current usage. I've tested it on a few accounts and it's worked fine on them all.

(If the forum messes up the formatting heres the link:

Hope someone finds it useful. 



import sys, re
from mechanize import Browser
from BeautifulSoup import BeautifulSoup

# Optional: uncomment and hard code your account details here:
#myUsername = ''
#myPassword = ''

if len(sys.argv) == 3:
    username, password = sys.argv[1:]
        username, password = myUsername, myPassword
        print "usage: %s username password" % sys.argv[0]

# Browser
br = Browser()

# Load the login page:
url = '' # 26.07kb

# Select the first form:

# Fill in and submit:
br.form['USER'] = username
br.form['PASSWORD'] = password

# Navigate to the 'Current Usage Details' page:
req = br.click_link(text='Current Usage Details')
html = br.response().read()

# Load html into BeautifulSoup.
# We need to adjust the line that contains ""
# as it confuses the html interpreter.
myMassage = [(re.compile(""), lambda match: '')]
soup = BeautifulSoup(html,  markupMassage=myMassage)

# Extract some data and print:
account = soup.findAll('span')[2].string
if len(account.split(' ')[2]) != 8:
    print 'Sorry, the account must be a landline.'
    print '         Usage for:', account
    print 'Current usage plan:', soup.findAll('table')[3].findAll('td')[9].string.strip()
    print '                   ', soup.findAll('table')[3].findAll('td')[7].string
    print ''
    data = soup.findAll('table')[9].findAll('td')
    print '   Total Downloads:', data[1].string
    print '     Total Uploads:', data[3].string
    print '       Total Usage:', data[5].string

Create new topic
78 posts

Master Geek

  # 308556 17-Mar-2010 23:37
Send private message

Thanks! I might try to adapt it for another ISP or two. :)

26 posts


  # 308564 17-Mar-2010 23:56
Send private message

I should have mentioned that you'll need to install mechanize and BeautifulSoup for this script to work. Mechanize handles the browser object (links / forms / cookies etc), and BeautifulSoup makes it easy to parse the html and pull out the data.

Charles, it should be easy enough to modify for other ISPs, as long as they use html and not flash / java etc. Post back if you get anything working.


4360 posts

Uber Geek

Lifetime subscriber

  # 308575 18-Mar-2010 06:10
Send private message

So what does this give you, that TUC doesnt?

26 posts


  # 308644 18-Mar-2010 10:25
Send private message

What do you mean by TUC?

All this does is let you get your usage from a command line. At work I have to keep an eye on all our broadband plans so I have a script that goes through them one by one and spits out the current usage. Makes it easy to keep an eye on them.

25 posts


  # 308648 18-Mar-2010 10:38
Send private message

Lovely, thanks Tom.

A real pity XTRA don't have an API that you can adopt to make things easier.

4360 posts

Uber Geek

Lifetime subscriber

  # 308668 18-Mar-2010 11:02
Send private message

tomhenderson: What do you mean by TUC?

All this does is let you get your usage from a command line. At work I have to keep an eye on all our broadband plans so I have a script that goes through them one by one and spits out the current usage. Makes it easy to keep an eye on them.

TUC, is traffic usage checker. Handy little app that sits in your taskbar.

26 posts


  # 308681 18-Mar-2010 11:28
Send private message

Thats a neat little app. My machine is a mac so not an option for me though. I do use a 'Consume' which is a great iPhone app which works with xtra. You can load in all your accounts and it shows them all as progress bars.


2182 posts

Uber Geek


  # 309205 19-Mar-2010 16:23
Send private message

rscole86: So what does this give you, that TUC doesnt?

Access to the figures from a unix shell prompt? Thus making it scriptable?

Not really interesting for most people, but I think it's quite neat. Now, make it work with TCL please ;)


26 posts


  # 429270 20-Jan-2011 17:37
Send private message

Updated this recently when telecom changed their system slightly. This version now cycles through every line listed on your account, doesn't break if you have a mobile plan listed, and prints usage from previous months.

Edit: Sorry guys, this forum won't seem to let me paste code with the formatting correct (no idea how I did it last time). Since this is python it won't run if the indentation is incorrect. The script at the link in my original post is updated to what I was trying to post here.

Create new topic

Switch your broadband provider now - compare prices

Twitter and LinkedIn »

Follow us to receive Twitter updates when new discussions are posted in our forums:

Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:

Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:

News »

Ring launches indoor-only security camera
Posted 23-Jan-2020 17:26

New report findings will help schools implement the digital technologies curriculum content
Posted 23-Jan-2020 17:25

N4L to upgrade & support wireless internet inside schools
Posted 23-Jan-2020 17:22

Netflix releases 21 Studio Ghibli works
Posted 22-Jan-2020 11:42

Vodafone integrates eSIM into device and wearable roadmap
Posted 17-Jan-2020 09:45

Do you need this camera app? Group investigates privacy implications
Posted 16-Jan-2020 03:30

JBL launches headphones range designed for gaming
Posted 13-Jan-2020 09:59

Withings introduces ScanWatch wearable combining ECG and sleep apnea detection
Posted 9-Jan-2020 18:34

NZ Police releases public app
Posted 8-Jan-2020 11:43

Suunto 7 combine sports and smart features on new smartwatch generation
Posted 7-Jan-2020 16:06

Intel brings innovation with technology spanning the cloud, network, edge and PC
Posted 7-Jan-2020 15:54

AMD announces high performance desktop and ultrathin laptop processors
Posted 7-Jan-2020 15:42

AMD unveils four new desktop and mobile GPUs including AMD Radeon RX 5600
Posted 7-Jan-2020 15:32

Consolidation in video streaming market with Spark selling Lightbox to Sky
Posted 19-Dec-2019 09:09

Intel introduces cryogenic control chip to enable quantum computers
Posted 10-Dec-2019 21:32

Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.

Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron

Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.