Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How do I convert this wget to perl?

by atcroft (Abbot)
on Oct 03, 2015 at 21:15 UTC ( [id://1143727]=note: print w/replies, xml ) Need Help??


in reply to How do I convert this wget to perl?

With LWP::UserAgent, you can specify a "cookie jar" file by doing the following:

# Assumes $ua is an LWP::UserAgent object use HTTP::Cookies; my $cookie_jar = HTTP::Cookies->new( file => "./lwp_cookies.dat", autosave => 1, ); $ua->cookie_jar($cookie_jar);

You can then use the $cookie_jar->add_cookie_header() method to potentially pre-load the cookie jar with the value. You may also be able to do so instead by using the additional arguments of the $lwp->get() method, similar to the following (untested):
$ua->get( $url, ':content_file' => 'file.bin', 'Cookie' => '...', );

Hope that helps.

Replies are listed 'Best First'.
Re^2: How do I convert this wget to perl?
by Todd Chester (Scribe) on Oct 04, 2015 at 00:44 UTC

    Sorry for being slow here, but I am having trouble wrapping my mind around what is going on with

    $ua->get( $url, ':content_file' => 'file.bin', 'Cookie' => '...', );

    Do I create 'file.bin'?

    or does the 'get' do that?

    What goes in the '...' part of the 'Cookie'?

    Does this download the cookie for me?

    And I guess I do not understand what a cookie is. I thought it was "oraclelicense=accept-securebackup-cookie" or is that the name of something else that has to be downloaded?

    Do I do a second 'get' to download the .exe file after the above? or does the above do the whole thing?

      See LWP::UserAgent. The ->get method sends a GET request and downloads the response to the file file.bin as per the :content_file argument.

      I don't find a special Cookie argument documented for ->get though, so I suspect that this won't work to set the cookie header as you want it. I think you will have to use HTTP::Cookies to set the cookie to the value you want.

        it give me the finger wag about not pressing the agree license button

Log In?
Username:
Password:

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

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

    No recent polls found