On 5/16/19 9:56 PM, Shlomi Fish wrote:
On Thu, 16 May 2019 13:13:16 +0200
hwilmer <h...@gc-24.de> wrote:

On 5/11/19 11:07 AM, Shlomi Fish wrote:
[...]
So I would want to use something like


my $binary_data = `curl -k "https://www.example.com/some.jpg"`;

Perl distinguishes between 8-bit/binary strings and unicode ones. See
https://perldoc.perl.org/perlunitut.html .

What kind of string do I get when using backticks like in the above
example?
> [...]
Perhaps use open "-|" with an encoding - see
https://perldoc.perl.org/functions/binmode.html .

I didn't know I could do that ...  I tried it and it works, too.

Note however that you should see https://perl-begin.org/uses/web-automation/
and use a module instead of trapping curl.exe's output. Perl has bindings to
libcurl too if that is what you want.

First I tried to use WWW::Mechanize, and that failed because it can't
deal witch the self-signed certificates the web server is using.  I
couldn't find anywhere in the documentation how to allow such
certificates.  Otherwise it seemed to be able to do what I wanted.


See
https://stackoverflow.com/questions/47662461/how-to-accept-self-signed-certificates-with-
lwpuseragent

That gives an error: 'Bareword "IO::Socket::SSL::SSL_VERIFY_NONE" not allowed while "strict subs" in use ...'. But this works:

      my $ua = LWP::UserAgent->new(
                                   max_size => $MAX_DOWNLOAD_SIZE,
                                   ssl_opts => {
                                                ssl_verify => 0,
                                                verify_hostname => 0
                                               }
                                  );

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to