use LWP::UserAgent;

my $ua = new LWP::UserAgent;
my $url = "http://www.google.ca/search?q=perl+lwp+tutorial";;
my $response = $ua->get($url);
if($response->content_type ne "text/html"){
    die("Recieved content-type ".$response->content_type.", was
looking for text/html.")
}
my $content = $response->content; # $content now holds the html page
from google.
print $content;

OR:

use LWP::Simple;

my $url = "http://www.google.ca/search?q=perl+lwp+tutorial";;
my $content = get($url);
die "Couldn't get $url." unless defined $content;
# $content now contains the html page from google.
print $content;

On Sun, May 17, 2009 at 2:10 PM, steve silvers <stevesilv...@hotmail.com> wrote:
>
> I have looked over the LWP documentation but still have trouble putting the
> pieces together. Can someone give me a snippet that shows me how to query
> google for something, "and display the results". The examples only show how
> to match on something and just print that out. How do I display the results,
> or format the results?
>
> Thanks in advance.
>
> ________________________________
> HotmailĀ® goes with you. Get it on your BlackBerry or iPhone.
> _______________________________________________
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to