[oclug] Re: access to a website with PERL
Glenn Jackman
glennj at ncf.ca
Wed Apr 21 13:32:30 EDT 2004
On 2004-04-21 12:56, Bob Lockie wrote:
> I am trying to access a web site with PERL.
>
> I can telnet to the site but when I do it from PERL, I get:
> HTTP/1.1 400 Bad Request
>
> The code is at:
> http://www.lockie.ca/test/ip.pl
Check out these modules: LWP::UserAgent, HTTP::Request, HTTP::Response
use LWP::UserAgent;
my $url = 'http://www.google.ca';
my $ua = LWP::UserAgent->new;
my $response = $ua->request( HTTP::Request->new('GET', $url) );
my $status = $response->status_line;
my $header = $response->headers->as_string;
my $data = $response->content;
--
Glenn Jackman
NCF Sysadmin
glennj at ncf.ca
More information about the OCLUG
mailing list