Ashish Mukherjee <[EMAIL PROTECTED]> writes:
> Hello everyone!
>
> I am facing a problem using LWP inside an ePerl page. The following
> piece of code returns nothing in the ePerl page but runs fine in a
> non-Web script.
>
> use LWP::Simple qw($ua get);
> print get ( 'http://www.google.com/index.html' );
In this case the full LWP library is used and the client identify
itself as; "libwww-perl/#.##". You can change to it with:
$ua->agent("foo");
> However, when I change the code to this (i.e don't import $ua),
>
> use LWP::Simple qw(get);
> print get ( 'http://www.google.com/index.html' );
>
> it works perfectly well in the Web page and shows me the Google home
> page.
In this case simplified implementation is used that identify itself as
"lwp-trivial/#.##"
> What could be the reason for this bizarre behaviour and how can I fix
> it?
Google is known to block requests that send "User-Agent: libwww-perl"
so my guess is that it would work if you did:
use LWP::Simple qw($ua get);
$ua->agent("foo"); # hide the fact that this is libwww-perl
print get ( 'http://www.google.com/index.html' );
Google want you to use their Web service interface for scripting.
Regards,
Gisle