Search code examples
perlwebhostingserver-side

Perl getprint() returns nothing


Sorry, I'm new to Perl, however, this seems really weird to me.

The point is: I have a perl script with this content:

#!/usr/bin/perl

print "Content-type:text/html\n\n";
use LWP::Simple;

getprint("http://DOMAIN/");

And I host it on some domain. The point is that it does work with every domain I enter except for my domain and the domain of the hosting company (including their service domains like those for admin tools and so on)...

I'm really confused with that, no idea what I'm doing wrong


Solution

  • You should modify your script a bit for the first, with some kind of "try-catches" or "die(...) if ..." structure and further if you script works on more domains, but not on yours or some certain domains, it means that they don't like crawlers :-). There are many ways to make some workarounds, try to identify your script throw LWP like some "browser" ( you have to many examples in the 'www' ) and the second think is - use first some normal PC as a client, cause it is possible that your server ip can be ban i some of the dark lists, but this is less possible.


    use LWP; my $userAgnt = LWP::UserAgent->new;

    print "Content-type:text/html\n\n";

    die "no success :-(" unless defined $userAgnt->get("DOMAIN");

    $userAgnt->getprint("DOMAIN/");

    or

    if (is_success($userAgnt->getprint("DOMAIN"))) { ... }

    Cheers.