Small script which display “teletekst” pages from the Dutch teletext (or the Belgium, but I’ve never used that).

I’m not the original author, but feel free to grab your copy.

#!/usr/bin/perl
#
# Dit scriptje laat de NOS teletext zien
#
# (c) 2001, 2002, 2003 by Bas Zoetekouw <bas@debian.org>
# All rights reserved.
# 
# Naar een idee van Wouter Bergmann-Tiest
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice and this list of conditions.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice and this list of conditions in the
#    documentation and/or other materials provided with the distribution.
#
#
## 2003-01-06: niew teletekst format
## 2003-01-06: kleurtjes
## 2003-01-06: meer html entities toegevoegd (dank Richard)
## 2003-01-22: VRT support
## 2003-02-07: kleur support aangepast

#use strict;

#my $SOURCE = "VRT"; 
my $SOURCE = "NOS"; 
my $LYNX;

foreach my $l (qw|/usr/bin/links /usr/bin/lynx lynx|) {
if (-x $l) {
    $LYNX=$l; last;
}
}

my $color = 1;
if ((scalar @ARGV > 0) && ($ARGV[0] eq "-m")) {
$color = 0;
shift @ARGV;
}

my %COLORS = ( "000000" => "\e[30m",  #black
	   "black"  => "\e[30m",  #black
	   "ff0000" => "\e[31m",  #red
	   "red"    => "\e[31m",  #red
	   "00ff00" => "\e[32m",  #green
	   "lime"   => "\e[32m",  #green
	   "0000ff" => "\e[34m",  #blue
	   "blue"   => "\e[34m",  #blue
	   "ffff00" => "\e[33m",  #yellow
	   "yellow" => "\e[33m",  #yellow
	   "ff00ff" => "\e[35m",  #magenta
	   "fuchsia"=> "\e[35m",  #magenta
	   "00ffff" => "\e[36m",  #cyan
	   "aqua"   => "\e[36m",  #cyan
	   "ffffff" => "\e[37m",  #white
	   "white"  => "\e[37m",  #white
	   "reset"  => "\e[0m");  #reset color
my %HTML   = ( "&quot;" => '"',
    "&shy;"  => "",
    "&lt;"   => '<',
    "&amp;"  => '&',
    "&gt;"   => '>');


sub display(\@) {
my @Output=@{(shift)};
my ($print, $last) = (0, 0);
foreach my $line (@Output) {
#	print "--> $line";
    ($print = 1) if ($line =~ s/^.*<pre>//i);
    ($last  = 1) if ($line =~ s/<\/pre>.*$//i);

    next unless ($print==1);

    if ($color==1) { 
	foreach (keys %COLORS) {
	    $line =~ s/COLOR=$_[^>]*>/>$COLORS{"$_"}/ig;
	} 
    }
    foreach (keys %HTML) {
	$line =~ s/$_/$HTML{"$_"}/ig;
    } 
    $line =~ s,<[^>]+>,,g;

    last if ($last == 1);

    print $line;

} 
print $COLORS{"reset"};
}

my ($Pagina, $SubPagina) = @ARGV;

$Pagina    = "100"  if  (scalar @ARGV == 0);
$SubPagina = "1"    if  (scalar @ARGV <= 1);  

my @Output = ("");
if ($SOURCE eq "NOS") {
$SubPagina = sprintf("%02i", $SubPagina);
@Output = `$LYNX -source 'http://teletekst.nos.nl/tekst/${Pagina}-${SubPagina}.html'`;
} elsif ($SOURCE eq "VRT") {
@Output = `$LYNX -source 'http://193.121.55.225/tt/tt.php?p=${Pagina}/${SubPagina}&g=0&s=0&r=0&x=1'`
}

display @Output;