znu has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I'm trying to write a perl script to download real time stock quotes from a website. The site requires authentication first and seems to do this using cookies. A url that will directly obtain the quote is: http://finance.ninemsn.com.au/money/shares/login.asp?page=/money/shares/live_stock_quote.asp?asx=KAZ&username=znubeen&password=znubeen This works fine from a browser, but not using wget or the like. How can I use perl to recieve and feed the cookie back to the server?

Replies are listed 'Best First'.
Re: Returning cookies to a webserver
by stefan k (Curate) on Aug 29, 2001 at 14:00 UTC
    I think it should be possible using the LWP module. A quick glance at man lwpcook and searching for 'cookies' gives:
    use LWP::UserAgent; use HTTP::Cookies; $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave => 1)); # and then send requests just as you used to do $res = $ua->request(HTTP::Request->new(GET => "http://www.yah +oo.no")); print $res->status_line, "\n";
    So have a look at man HTTP::Cookies to get more information...

    Regards... Stefan
    you begin bashing the string with a +42 regexp of confusion