X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=blobdiff_plain;f=public_html%2Fcgi-bin%2Fidnes-foto;fp=public_html%2Fcgi-bin%2Fidnes-foto;h=eaa15c91972731a087093e71359b4394ab9f563b;hp=0000000000000000000000000000000000000000;hb=f262b352b1da192913af430249ea764d73398667;hpb=20cdc4fa3e0efd1a30b4c79b97394154b8428868 diff --git a/public_html/cgi-bin/idnes-foto b/public_html/cgi-bin/idnes-foto new file mode 100755 index 0000000..eaa15c9 --- /dev/null +++ b/public_html/cgi-bin/idnes-foto @@ -0,0 +1,73 @@ +#! /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