develooper Front page | perl.beginners | Postings from May 2019

Re: can I use some kind of binary string?

Thread Previous | Thread Next
From:
hwilmer
Date:
May 18, 2019 12:03
Subject:
Re: can I use some kind of binary string?
Message ID:
374c2acc-727d-947f-faaf-fb3bbcc19292@gc-24.de
On 5/16/19 9:56 PM, Shlomi Fish wrote:
> On Thu, 16 May 2019 13:13:16 +0200
> hwilmer <hw@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
					       }
				  );

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About