#! /usr/bin/perl use strict; use warnings; require LWP::Simple; require URI::Escape; $|=1; my $BASE; if (exists $ENV{"QUERY_STRING"}) { $BASE=($ENV{"QUERY_STRING"}=~m{^url=([^&]*)})[0]; $BASE=URI::Escape::uri_unescape($BASE); 0==@ARGV or die "ARGV count != 0"; $BASE||=""; } else { 1==@ARGV or die "ARGV count != 1"; $BASE=$ARGV[0]; } if ($ENV{"GATEWAY_INTERFACE"}) { print <<"EOH"; Content-type: text/html; charset=windows-1250 EOH } print <<"EOH"; iDNES foto@{[ (!$BASE ? "" : ": $BASE") ]}
EOH $BASE=~m{^http://\w+\Q.idnes.cz/foto.asp?\E(?:r=\w+&c=\w+|c=\w+&r=\w+)$} or $BASE=""; if ($BASE) { my $pageno=1; my %seen; my %seen_p_text; PAGES: for (;;) { my $pageurl=$BASE.'&strana='.$pageno; my $page=LWP::Simple::get($pageurl) or die $pageurl; my $did=0; while ($page=~m{ EOH my $infourl=$BASE.'&styl=zoom&foto='.$base; my $info=LWP::Simple::get($infourl) or die $infourl; $info=~m{

[^<]*

} or die "No text found: $infourl"; my $p_text=$&; print <<"EOH" if !$seen_p_text{$p_text}++; $p_text EOH } die $pageurl if !$did; $pageno++; } } print <<"EOH";

EOF

EOH