use WWW::Robot; print "Please input the URL of the site to be searched \n"; my $url_name = ; # The user inputs the URL to be searched #Create an instance of the webcrawler my $web_crawler = new WWW::Robot(NAME => 'My WebCrawler', VERSION => '1.000', USERAGENT => LWP::UserAgent->new, EMAIL => 'aca03lh@sheffield.ac.uk', ); #Below the attributes of the web crawler are set $web_crawler->addHook('invoke-on-all-url', \&invoke_test); $web_crawler->addHook('follow-url-test', \&follow_test); $web_crawler->addHook('invoke-on-contents', \&invoke_contents); # to be able to get contents from webpages $web_crawler->addHook('add-url-test', \&add_url_test); # if url doesn't exist in array then add for visit $web_crawler->addHook('continue-test', \&continue_test); # to exit loop when we run out of URL's to visit sub invoke_contents { my ($webcrawler, $hook, $url, $response, $structure) = @_; our $contents = $structure; #To make the string that has the contents in global } # Start the web crawling $web_crawler->run($url_name); print $contents;