The trick you mention using the url "http://www.google.com/search?q=perl" (and various extensions) works just fine from Firefox or IE browsers.
HOWEVER, this fails when I call the same url using perl as in:
my $ua = new LWP::UserAgent;
my $req = HTTP::Request->new(GET => $url);
my $res = $ua->request($req);
Instead google returns a long error message of which I have exercepted the following key snippet:
Your client does not have permission to get URL xxxx from this server. (Client IP address: xxx.xxx.xxx.xxx).
Please see Google's Terms of Service posted at http://www.google.com/terms_of_service.html
I suppose that Google recognizes that I am not using a standard browser and assumes (perhaps correctly) that I must be violating their TOS.
Is there any way to get around this? i.e. can I make my perl code look like a valid browser?
I would prefer a simple method that doesn't require in-depth knowledge of (or access to) Google APIs or other specialized perl modules.
|