I'm unable to use perl module LWP::Parallel::UserAgent for https websites. The following is the code I use:
#!/usr/bin/perl
use LWP::Parallel::UserAgent qw(:CALLBACK);
use HTTP::Request;
my $BrowserName = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36";
my $pua = LWP::Parallel::UserAgent->new();
$pua->agent( $BrowserName );
$pua->nonblock('true');
$pua->in_order (1);
$pua->duplicates(0);
$pua->timeout (10);
$pua->redirect (2);
$pua->remember_failures ( 1 );
$url = "https://www.squeezemind.it";
my $res = $pua->register( HTTP::Request->new('GET', $url), \&gestione_risposta, 4096 );
my $entries = $pua->wait();
# Leggo le risposte
foreach (keys %$entries) {
my $res = $entries->{$_}->response;
print "\n\nAnswer for '",$res->request->url, "' was ", $res->code,": ", $res->message;
}
sub gestione_risposta {
my($html_content, $response, $protocol, $entry) = @_;
if( !$response->is_success || $response->code != 200 ) { return C_ENDCON; }
if( length($html_content) ) {
# Bla Bla
}
return undef;
}
It works well for http but if you try to change $url with a https website it fails.
For https://www.squeezemind.it:
Error code: 500 Message: Can't locate object method "get_cipher" via package "IO::Socket::INET" at /usr/share/perl5/LWP/Protocol/https.pm line 119
For https://www.stackoverflow.com:
Error code: 402 Message: Unexpected EOF while reading response
The system is up to date. Suggestions?
Thank you!
perl -MIO::Socket::SSL=debug9 program.pl
and add the output to your question. And please try it also with a simple LWP::UserAgent instead of LWP::Parallel::UserAgent. – Steffen Ullrichget_cipher
isn't on line 119 of the latest version of LWP::Protocol::https – ikegami