in reply to Re: LWP and Mechanize
in thread LWP and Mechanize

This is very helpful! Thank you very much. How to print out content during the else condition?

Replies are listed 'Best First'.
Re^3: LWP and Mechanize
by pryrt (Abbot) on May 21, 2022 at 21:14 UTC
    How to print out content during the else condition?

    That was in my edit2 section: else {die $response->status_line . ($response->content||'');}

    Or, putting it into your whole script:

    use strict; use warnings; use LWP::UserAgent(); my $ua = LWP::UserAgent->new(timeout => 10); $ua->env_proxy; my $response = $ua->get('https://www.sec.gov/Archives/edgar/full-index +/2019/QTR1/master.idx'); open(OUT, ">" . "master") or die "Cannot open master"; if ($response->is_success) {print OUT $response->decoded_content; } else {die $response->status_line . ($response->content||'');} close OUT;

      I see now. Can you tell me how to set up the user agent?