[vox-tech] Getting https with perl

Jim Angstadt vox-tech@lists.lugod.org
Tue, 1 Jul 2003 16:41:08 -0700 (PDT)


Hi All,

I'm trying to get https pages with perl.  

A previous msg [1] led me to install 
Crypt-SSLeay and OpenSSL, which went good.

Now I've got code that looks bad and works
poorly.

  my $ua = LWP::UserAgent->new( timeout => 20, )
	|| die "Cannot create new LWP UserAgent: $! \n";
  my $req = HTTP::Request->new('GET', $url )
	|| die "Cannot create LWP Request: $! \n";
  $ua->request($req, \&callback, $block )
	|| die "Cannot request data: $! \n";

  sub callback
    {
	my ($html, $response, $protocol ) = @_;
	$html =~ s/^<html>.*Synopsis//;
	print LOG "\n\t html: \n $html \n";
	my @tr = $html =~ /<tr>.*?<\/tr>/gis;
	print LOG "\t Table rows: \n", join("\n", @tr),
"\n";
    }

The code gets delivered in chunks, so the print
statements are repeated.  Setting $block to 50k
(bigger than the page) did not help.

I'd prefer a simple assignment of the html 
to a scalar, like lwp::simple get does for 
http pages.  But my attempts with that approach 
all end with a hash reference printed.

Thanks,
Jim

[1]
http://lugod.org/mailinglists/archives/vox-tech/2000-12/msg00085.html



__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com