Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

LWP Analysis

by spatterson (Monk)
on Jan 05, 2007 at 14:29 UTC ( #593114=snippet: print w/ replies, xml ) Need Help??

Description: I sometimes need to check exactly what data a webserver has returned for a URL without letting a browser interfere & reinterpret any of it, so this perl script follows me around.

It will print out the HTTP header (including cookies) and the full body for a URL given on the command line.

#!/usr/bin/perl -w

use LWP::UserAgent;
my $ua = LWP::UserAgent->new(
                             keep_alive => 1,
                             timeout => 30,
                             debug => 1
                             );
my $body = $ua->get($ARGV[0]);
print $body->as_string;
Comment on LWP Analysis
Download Code
Re: LWP Analysis
by merlyn (Sage) on Jan 05, 2007 at 15:54 UTC
      or
      GET http://www.example.com/

      ( or not. see the reply. )

        Modern LWP defaults to not install GET any more, since it's merely a subfunction of lwp-request, and might collide with other tools too easily.

        Also, GET as you've invoked it doesn't show the headers.

Re: LWP Analysis
by ww (Bishop) on Jan 05, 2007 at 16:04 UTC
    Minor note

    Under winXP & AS 5.8.8 (819), and PRIOR to commenting out "debug => 1"
    OP's code spits out a warning

    Unrecognized LWP::UserAgent options: debug at (line ref to "debug => 1")

    before proceeding to produce the expected output.

    Haven't investigated reason yet, but a very handy snippet, indeed! Thank you, spatterson

Back to Snippets Section

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2015-07-04 04:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls