#!/usr/bin/perl -w # # Last changed: 1999-04-16 0900BST # this code lives at http://www.ntk.net/btbill/bill.pl # if it breaks, e-mail me at danny@spesh.com, and we'll # put a fixed version at that location. # # Note: you'll need also need the SSLeay-0.6.6 library from Eric Young and co, # and Net::SSL from the Crypt-SSLeay Perl bundle. That's because this simple # hack needs to get the page using secure http (https). Aha. Not so easy as # you thought. # # Where to get SSLeay: # Source master ftp site: ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL # Mirrors are listed at: http://www.psy.uq.edu.au:8080/~ftp/Crypto/ # Redhat users, try http://www.replay.com/redhat/ssl.html # (Remember to get the 0.6.6 version. Remember not to break any import/export # laws your country has regarding strong encryption systems.) # # Where to get Net::SSL # It lives in Crypt-SSLeay-0.07, which lives on CPAN # if you're not using "perl -MCPAN -e shell" to get your modules, look for it # at: http://www.cpan.org/modules/by-module/Net/Crypt-SSLeay-0.07.tar.gz # # Well-read browsers will note that this code is a blatant rip-off of the # examples given in Jon Orwant and Dan Gruhl's "Five Quick Hacks" article in # the continually excellent Perl Journal #13 . Have we # had enough comments yet? use LWP::UserAgent; use HTTP::Request::Common; $PHONE_NO="01715551234"; # Your phone number $CUST_NO="NT12345678"; # The Customer Number on the top left of your BT bill $ua=new LWP::UserAgent; $resp=$ua->request(POST 'https://www.customer-service.bt.com/view_my_bill/owa/vmb_internet.vmb_getBillUsage', [ "Telephone" => $PHONE_NO, "CustRef" => $CUST_NO]); exit -1 unless $resp->is_success; $_=$resp->{_content}; s/<[^>]+>//g; s/^.*yesterday//s; s/This excludes.*$//s; if (defined $ARGV[0] and ($ARGV[0] eq "machine")) { $date=`date +"%Y-%m-%d"`; chop($date); ($bottom_line)=m/£([\d\.]+)/; $bottom_line="???.??" unless ($bottom_line =~ /\.\d\d\s*$/); print "$date $bottom_line\n"; } else { print; }