Get Telstra Bigpond Usage from the command line

linux Apr 02, 2015

If you feel the need to get your Telstra Bigpond usage from the command line, say for putting into a round-robin database for drawing pretty graphs, then give this a go:

#!/usr/bin/env python2.7
import requests, sys, re
from bs4 import BeautifulSoup
data = {'username': 'steve.smith', 'password': 'somethingsecret!'}
req ='', params=data, allow_redirects=False)

if req.status_code == 302:
    cookies = {'BPSESSION': req.cookies['BPSESSION']}
    headers = {'Referer': ''}
    req = requests.get('', headers=headers, cookies=cookies)
    print "Didn't get redirected? ", req.status_code
if req.status_code == 200:
    # html.parser is important as it will ensure the document is parsed as
    # html rather than xml
    soup = BeautifulSoup(req.text, 'html.parser')
    usage = int(soup.find(class_='trStyleTotal').find('b').text) / 1e3
    limit = soup.find('th', text="Monthly allowance")'\r\n\t')
    limit = re.match('\d+', limit).group()
    print usage, "/", limit, "GB"
    print "Couldn't get usage page ", req.status_code

Grab it from GitHub


 [email protected]:~$ python
 195.525 / 500 GB


Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.