in reply to HTTP::Request questions
Update: OK, so I didn't see your declaration of $bot as a LWP::UserAgent there. However, I've never seen a call like this one that you have: $response->content($req). What does passing the HTTP::Request object to the content method do, if anything? Also notice that you're printing $pic to the zippy.gif file, but $pic is only a blessed hash reference. This is probably not what you want. Do you want to write $pic->content to the filehandle instead?use HTTP::Request::Common; use LWP::UserAgent; use HTTP::Headers; my $refer = 'http://www.kingfeatures.com'; my $url = 'http://www.kingfeatures.com/stuff...'; my $agent = LWP::UserAgent->new(keep_alive => 1, timeout => 10, ); # change this to masquerade as a browser if the site requires it. my $hdrs = new HTTP::Headers(User-Agent => 'My friendly LWP script') +; $hdrs->referrer($refer); my $req = new HTTP::Request(GET => url, $hdrs); my $response = $agent->request($req); # $response is a HTTP::Response object. if ($response->is_success) { # you now have access to info like $response->headers # print 'Content-type: ' . $response->headers->content_type . "\ +n\n"; # but what you probably want is in here: print $response->content; }
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: HTTP::Request questions
by Popcorn Dave (Abbot) on Oct 26, 2002 at 21:14 UTC |