On Thursday, Nov 6, 2003, at 15:12 US/Pacific, Tobias Fink wrote: [..]
why doesn't

my $ua = LWP::UserAgent->new;
my $res = $ua->request(GET 'http://www.google.de/search', q => 'asdasd');
if ($res->is_success) {
my $server_response = $res->content;
print $server_response;
}


print the html-source of http://www.google.de/search?q=asdasd ?

well there seems to be a series of issues, not the least of which is that when I try the simple command line routine with the lwp-request code I get a 'forbidden' response back from www.google.com - so even IF I can put the string

http://www.google.com/search?q=asdasd

into a browser, the simple request
[jeeves: 13:] lwp-request 'http://www.google.com/search?q=asdasd'
<HTML>
<HEAD><TITLE>An Error Occurred</TITLE></HEAD>
<BODY>
<H1>An Error Occurred</H1>
403 Forbidden
</BODY>
</HTML>
[jeeves: 14:]

suggest that they may have 'issues' with web-bots. which you
would notice with say code like:

        my $res = $ua->get('http://www.google.com/search?q=asdasd');
        if ($res->is_success) {
                 my  $server_response = $res->content;
                 print $server_response;
        } else {
                print "request failed\n";
                print $res->content ;
        }

At which point let us go back and look at the problem
with your line

my $res = $ua->request(GET 'http://www.google.de/search', q => 'asdasd');

sorry, but that just does NOT make sense to me. I can see what you were
trying to do, but that is way garbled.

IF you know what your query should be, then why not append it to
the base 'uri' that you have....

if you will go back to

perldoc LWP::UserAgent

you will note that the more classical form, if you do not
want to do the 'get()' method is to construct the HTTP::Request object,
( cf HTTP::Request ) and pass that object:

     $request = HTTP::Request->new('GET', 'http://search.cpan.org/');
      # and then one of these:
     $response = $ua->request($request);

so yes, the line is broken, but there also seems to be an interesting
server side issue that google has with web-bots.


ciao drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to