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

Re: can I use some kind of binary string?

Thread Previous
From:
Shlomi Fish
Date:
May 18, 2019 12:38
Subject:
Re: can I use some kind of binary string?
Message ID:
20190518151800.0442e5f2@telaviv1.shlomifish.org
Hi,

On Sat, 18 May 2019 14:02:46 +0200
hwilmer <hw@gc-24.de> wrote:

> 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.
> 

Nice.

> >>> 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
> 					       }
> 				  );
> 

Great! Thanks for the tip.

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
https://is.gd/MQHVF3 - The Atom Text Editor edits a 2,000,001B file

The Bajoran scholars have positively identified Benjamin Sisko as The Emissary.
They also positively identified the NSA headquarters as The Dungeon.
    — http://www.shlomifish.org/humour/bits/facts/NSA/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

Thread Previous


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