[LA.pm] playing with perl fire

David Heayn david at cloudgraphics.com
Tue Jun 7 18:51:34 PDT 2005


Recently I thought it would be a good idea to circumvent the proxy 
blocker at work that disallows web browsing of "questionable" sites. 
So I built a very simple LWP mirroring script which works really well.

However, my little hack has a shortcoming, the pictures are still 
being pulled off the "questionable" site and are blocked.

My question to the group is if there is a technique/library/method to 
grab those remote images, save it to a temp directory, then swap out 
the HTML <IMG> tags referencing the local files instead of the remote 
ones.

You're more than welcome to play with my work in progress:
http://www.cloudgraphics.com/cgi-bin/url.cgi

And here's the source code (mostly ripped off the 'net)
#!/usr/local/bin/perl -w
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
     warningsToBrowser(1);
use lib qw( ..);
use HTML::TableExtract;
use LWP::Simple;
use Data::Dumper;

my $cgi = "http://www.cloudgraphics.com/cgi-bin/url.cgi";
my $version = "Grabber v 1.0";
if (param('url'))
	{
	print header,
	start_html('NET Grabber'),
	my $url = param('url');
	use LWP::Simple;
	my $baseurl = $url;
	my ($http, $oo, $base) = split (/\//, $baseurl);
	my $content = get $url;
			$content =~ 
s/href=\"http:\/\//href=\"$cgi\?url=http:\/\//ig;
			$content =~ s/href=\"\//href=\"$cgi\?url=$url/ig;
			$content =~ s/href='\//href='http:\/\/$base\//ig;
			$content =~ s/href=\//href=http:\/\/$base\//ig;
	print $content;
	end_html;
	}
else
	{
	print header,
		start_html('NET Grabber'),
		h1('URL Grabber'),
		hr;
	print startform;
	print textfield(-name=>'url',
			-value=>'http://',
			-size=>60);

	print submit(-name=>'action',
	value=>'Process'),
		end_form;
		hr,
		end_html;
		}



Cheers!
David Heayn * http://www.cloudgraphics.com * 213/925.3283


More information about the Losangeles-pm mailing list