From f262b352b1da192913af430249ea764d73398667 Mon Sep 17 00:00:00 2001 From: lace <> Date: Wed, 14 Jul 2010 11:12:57 +0000 Subject: [PATCH] idnes-foto-old0 --- public_html/cgi-bin/idnes-foto | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 public_html/cgi-bin/idnes-foto 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 -- 1.8.3.1