#!/usr/bin/perl -w $|=1; use strict; use diagnostics; use DBI; use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->agent("Munin[river_levels_]"); my $base = "http://apps.environment-agency.gov.uk/river-and-sea-levels/"; my $req = HTTP::Request->new(GET => $base . $ARGV[0] . ".aspx"); my $res = $ua->request($req); if ($res->is_success) { my @lines = split("\n", $res->content); foreach my $line (@lines) { if( $line =~ m~href="\?stationId=(\d+)" alt="([^"]+)"~ ) { my $stationId = $1; my $name = $2; print $stationId . " "; } } } else { die "failed!"; }