Hi monks,

First, I cannot install LWP::Parallel::UserAgent (it is not installable in debian sid). I would like to solve this problem without any other module (WWW::Mechanize ..., and other modules which can be found searching in the monastery).

How can I simulate next code in perl (just rewriting wget command with LWP module) ?
use threads; my $user="xxx"; my $password="yyy"; sub my_thread_sub { my ($url)=@_; my $cookie=to_string ($url); # to string convert url to an acceptable +filename my $WGET; if ( -e $cookie ) { open $WGET, "wget -q -O - -w 1 -T 1 -t 1 --load-cookies $cookie -- +user $user --password $password $url |"; } else { open $WGET, "wget -q -O - -w 1 -T 1 -t 1 --save-cookies $cookie -- +keep-session-cookies --user $user --password $password $url |" } local $/; $output=<$WGET>; ... return 0; } my @thrs; my @urls=qw("http://example1/" "http://example2/"); dontgo: my $i=0; foreach my $url (@urls) { $thrs[$i]=threads->new ("my_thread_sub",$url); $i++; } foreach my $thr (@thrs) { $thr->join; } sleep 3 goto dontgo; exit 0;

I tried to simulate it with LWP, but I fail when I want to load the previous cookie file (lwp saves always an empty cookie file).

I tried too loading file from wget cookie file, but lwp removes the content. I would like to maintain the http session in each url, and I wouldn't like to have running threads all the time (that is the other option)

So, without pointing me to another module (aka Threads::Pool), how can I s/wget/lwp/ in this case ?

Thank you very much !


In reply to Simulating --keep-session-cookies wget option with LWP ? by i5513

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.