download_html_perl

Repository which shows some of examples of downloading HTML from a URL
git clone git://git.samirparikh.com/download_html_perl
Log | Files | Refs | README

curl2lwp.pl (502B) - raw


      1 #!/usr/local/bin/perl
      2 
      3 # make sure you have installed:
      4 # LWP::UserAgent
      5 # LWP::Protocol::https
      6 
      7 #
      8 # taken from:
      9 # https://corion.net/curl2lwp.psgi
     10 #
     11 
     12 use strict;
     13 use warnings;
     14 use LWP::UserAgent;
     15 
     16 my $ua = LWP::UserAgent->new( 'send_te' => '0' );
     17 my $r  = HTTP::Request->new(
     18     'GET' => 'https://example.com',
     19     [
     20         'Accept'     => '*/*',
     21         'User-Agent' => 'curl/7.55.1',
     22         'Cookie'     => '90ip...pt71'
     23     ],
     24 
     25 );
     26 my $res = $ua->request( $r );
     27 print $res->decoded_content, "\n";