Thread get source code with LWP::UserAgent
(9 answers)
Opened by Gizmo at 2013-12-11 19:39 Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 #!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; my $url = "http://www.google.com/"; my $file="code.html"; my $ua = LWP::UserAgent->new(); my $rsp = $ua->get($url); if($rsp->is_success()) { open (my $fh, ">:raw", $file) or die "ERROR open $file ($!)"; print $fh $rsp->content(); close ($fh); } else { die $rsp->status_line(); } Last edited: 2013-12-11 19:51:35 +0100 (CET) |