Search code examples
perlgetlwp

perl get webpage error with LWP:Simple


I have a project I'm working on for school but I seem to be getting an error here...

I get "Can't call method 'content' on an undefined value at line 5"

use LWP::Simple;
for(my $id=0;$id<55;$id++)
{
    my $response = get("http://www.gamereplays.org/community/index.php?act=medals&CODE=showmedal&MDSID=" + $id );
    my $content = $response->content;    
        for(my $id2=0;$id2<10;$id2++)
        {
                $content =~ /<img src="http:\/\/www\.gamereplays.org\/community\/style_medals\/(.*)$id2\.gif" alt=""\/>/;
                $url = "http://www.gamereplays.org/community/style_medals/" . $1 . $id2 . ".gif";
                getstore($url, $1 . $id2 . ".gif");

        }
}

Solution

  • LWP::simple doesn't return a response object, it return directly a string containing the response body. And your put some pause between each request to avoid pounding the targeted website.