Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Unable to use WWW-Mechanize

by rich_d_thomas (Sexton)
on Jul 03, 2020 at 08:25 UTC ( [id://11118851]=perlquestion: print w/replies, xml ) Need Help??

rich_d_thomas has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have been trying to use this with the following code and result. I have tried forcing different versions of TLS and ignoring the server certificate. I have version 2.00 of the WWW-Mechanize module installed. The site itself supports TLS 1.1 and 1.2 I can wget to https://customer.bookingbug.com from the same machine that I'm trying this perl script from. Can anybody help please?
#!/usr/bin/perl use constant VERSION => "v1.06"; use strict; use warnings; use IO::Socket::SSL; use LWP; use LWP::UserAgent; use LWP::Debug; use WWW::Mechanize; LWP::Debug::trace('()'); $| = 1; # perform flush after each write to STDOUT my $url="https://customer.bookingbug.com"; my $initial_user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_ +3) AppleWebKit/534.53.11 (KHTML, like Gecko) Version/5.1.3 Safari/534 +.53.10'; my $mech; $mech=WWW::Mechanize->new( agent => $initial_user_agent, ); $mech->add_handler("request_send", sub { shift->dump; return }); $mech->get( $url ); printf($mech->content)
This is the result I get:
./s.pl GET https://customer.bookingbug.com Accept-Encoding: gzip User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit +/534.53.11 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10 (no content) Error GETing https://customer.bookingbug.com: Can't connect to custome +r.bookingbug.com:443 (LWP::Protocol::https::Socket: SSL connect attem +pt failed with unknown errorerror:140770FC:SSL routines:SSL23_GET_SER +VER_HELLO:unknown protocol) at ./s.pl line 35.

Replies are listed 'Best First'.
Re: Unable to use WWW-Mechanize
by hippo (Bishop) on Jul 03, 2020 at 08:35 UTC

    Well, the good news is that there's nothing inherently wrong with your code because I have downloaded and run it and it works fine (in the sense that there are no SSL errors and it retrieves a page of HTML from the server). So the bad news is that there's something in your environment which is causing the problem. I'd be looking at your versions of openssl, IO::Socket::SSL and (unlikely but still worth a check) Mozilla::CA for starters. Are they all up to date?

    (updated for clarity in the light of marto's 404 report)

      Thank you very much hippo, using CPAN to update IO::Socket::SSL has done the trick!
Re: Unable to use WWW-Mechanize
by marto (Cardinal) on Jul 03, 2020 at 08:31 UTC

    "https://customer.bookingbug.com"

    Visiting this in Firefox or Chrome gives me a page saying "Error: Request failed with status code 404", a 'view source' shows some JavaScript, a lot of commented out JavaScript, and some HTML, identical to the result of running your script at the command line.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11118851]
Approved by hippo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 02:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found