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

Thanks for all of your help on my last question dealing with saving text data off a web page. Here comes my next dilemma. When I am saving an html page, which requires a username/password, I use the following module:
use LWP::UserAgent; $ua = LWP::UserAgent->new; $req = HTTP::Request->new(GET=> 'http://www.linpro.no/secret/'); $req->authorization_basic('aas', 'mypassword'); print $ua->request($req)->as_string;
When it saves the web page to a file, I get the correct page, but on the very top of the page, is this code
HTTP/1.1 200 OK Connection: close Date: Wed, 20 Apr 2013 20:54:15 GMT +Pragma: no-cache Content-Length: 186386 Content-Type: text/html Clien +t-Date: Wed, 20 Apr 2005 20:54:24 GMT Client-Peer: 66.210.81.31:80 Cl +ient-Response-Num: 1 Refresh: 0360
How do you get rid of that?

Edited by Arunbear: Changed title from 'HTML', as per Monastery guidelines

Replies are listed 'Best First'.
Re: Stripping headers from a HTTP reply
by davidrw (Prior) on Apr 20, 2005 at 21:06 UTC
    I think that using the ->content() method instead of ->as_string() will limit it to what you're looking for.
Re: Stripping headers from a HTTP reply
by eibwen (Friar) on Apr 21, 2005 at 00:48 UTC
    The "code" to which you refer is actually the HTTP Headers:
    HTTP/1.1 200 OK Connection: close Date: Wed, 20 Apr 2013 20:54:15 GMT Pragma: no-cache Content-Length: 186386 Content-Type: text/html Client-Date: Wed, 20 Apr 2005 20:54:24 GMT Client-Peer: 66.210.81.31:80 Client-Response-Num: 1 Refresh: 0360

    Everything following the headers is the "HTTP content". Hence, you can use the content method as davidrw stated. You may also want to read the CPAN documentation for LWP::UserAgent as the sample code illustrates this very point.