You've solved my problem, Jeff.

Thank you....Thank you very much.

I really appreciate your help.

On Mon, 8 Oct 2007 10:20:00 +0800
"Jeff Pang" <[EMAIL PROTECTED]> wrote:

> 2007/10/8, Patrik Hasibuan <[EMAIL PROTECTED]>:
> 
> > But if I retrieve a little bit more complicated url such as 
> > "http://www.google.com/search?q=silicon+valley&start=20"; causes error.
> >
> > I need to retrieve this url: 
> > http://www.google.com/search?q=silicon+valley&start=20. I use "silicon 
> > valley" as the keyword.
> >
> 
> Hi,
> 
> Try this way below (got from perldoc lwpcook),it can work for me.
> 
>         use strict;
>         use LWP::UserAgent;
> 
>         my $uri = 'http://www.google.com/search?q=silicon+valley&start=20';
> 
>          my $ua = LWP::UserAgent->new;
>          $ua->agent("Mozilla/8.0"); # pretend we are very capable browser
> 
>          my $req = HTTP::Request->new(GET => $uri);
>          $req->header('Accept' => 'text/html');
> 
>          # send request
>          my $res = $ua->request($req);
> 
>          # check the outcome
>          if ($res->is_success) {
>             print $res->content;
>          }
>          else {
>             print "Error: " . $res->status_line . "\n";
>          }


-- 
Patrik Hasibuan <[EMAIL PROTECTED]>
Junior Programmer

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to