Accessing HTTPS URLs
When you want to get access to page through HTTPS all will work as well as in case we would deal ordinary HTTP with the report if you LWP has support HTTPS (through corresponding Secure Sockets Layer library). For example:
use LWP 5.64;
my $url = ' https: // www.paypal.com / '; * Yes, HTTPS!
my $browser = LWP:: UserAgent-> new;
my $response = $browser-> get ($url);
die " Error at $urln ", $response-> status_line, " n Aborting "
unless $response-> is_success;
print " Whee, it worked! I got that ",
$response-> content_type, " document! n ";
If you LWP has no support HTTPS then the answer will be not successful and you receive the following mistake:
Error at https: // www.paypal.com/
501 Protocol scheme ' https ' is not supported
Aborting at paypal.pl line 7. [or whatever program and line]
If you LWP has support HTTPS then the answer should be successful, and you should fulfil with $response as well as with kljubym the ordinary HTTP-answer.
For reception of the information on installation of support HTTPS for LWP read file README.SSL which is included into the distribution kit libwww-perl.
Reception of the big documents
When you request big (or potentially big) the document, arises a problem with standard actions with methods of searches (it is similar $response = $browser-> get ($url)) with that, that all object of the answer should be stored{kept} in memory. If the answer is 30-megabajtnyj a file it, to put it mildly, is not so good for your operative memory and the size of your process in her.
Good alternative is preservation of a file on a disk, instead of in memory. Syntax the following:
$response = $ua-> get ($url,
':content_file ' => $filespec,
);
For example,
$response = $ua-> get (' http: // search.cpan.org / ',
':content_file ' => '/tmp/sco.html '
);
When you use opciju:content_file, the object $response will have all normal headings, however $response-> content will be empty.
I shall note, that the option ":content_file" was not supported by old versions LWP, therefore you should take it into consideration, having added use LWP 5.66; for check of version LWP if you consider, that your program can be started on systems with older versions LWP.
If you want, that the program has been compatible with older versions LWP then use syntax which allows to make too most:
use HTTP::Request::Common;
$response = $ua-> request (GET ($url), $filespec);
[HTML] <h3> Links </h3> [/HTM]
Remember, that this clause{article} is only the very first introduction in LWP - for deeper studying LWP and the problems{tasks} connected with LWP, you should read the following materials:
*
LWP:: Simple: simple functions for uploading, rabora zagovkov and mirrorings of addresses.
*
LWP: the Review of modules libwww-perl.
*
LWP:: UserAgent: the Class for objects which play a role of " virtual browsers ".
*
HTTP::Response: the Class of objects which represent "answer", such as in $response = $browser-> get (...).
*
HTTP::Message and HTTP::Headers: Classes for granting a lot of methods for HTTP::Response.
*
URI: the Class for objects which represent absolute or relative URLy.
*
URI:: Escape: Functions for job with escape-sequences in addresses (for example transformation there and back from " this and that " v "this%20%26%20that").
*
HTML:: Entities: Functions for job with escape-sequences in HTML (for example transformation there and back from " C. and E. Bront and * 235; " v " C. *amp; E. Bront*euml; ").
*
HTML:: TokeParser and HTML:: TreeBuilder: Classes for grammatic analysis ("parsing") HTML.
*
HTML:: LinkExtor: the Class for a presence{finding} of links in documents.
*
And the last, but not the least, my book Perl and LWP.

|