Bonjour,
j'écrit ce script pour m'afficher les liens internes d'un sites web mais il ne retourne rien
<?php
// It may take a whils to crawl a site ...
set_time_limit(10000);
// Inculde the phpcrawl-mainclass
include_once('../PHPCrawl_083/PHPCrawl_083/libs/PHPCrawler.class.php');
// Extend the class and override the handleDocumentInfo()-method
$tab = array();
class MyCrawler extends PHPCrawler
{
function handleDocumentInfo(PHPCrawlerDocumentInfo $DocInfo)
{
// Just detect linebreak for output ("\n" in CLI-mode, otherwise "<br>").
global $tab;
if (PHP_SAPI == "cli") $lb = "\n";
else $lb = "<br />";
// Print the URL and the HTTP-status-Code
if(!in_array($DocInfo->url,$tab,true)){
array_push($tab,$DocInfo->url);
}
echo $lb;
flush();
}
}
// Now, create a instance of your class, define the behaviour
// of the crawler (see class-reference for more options and details)
// and start the crawling-process.
$crawler = new MyCrawler();
// URL to crawl
$crawler->setURL("[http://www.tunisie-web.org] ");
// Only receive content of files with content-type "text/html"
$crawler->addContentTypeReceiveRule("#text/html#");
// Ignore links to pictures, dont even request pictures
$crawler->addURLFilterRule("#\.(jpg|jpeg|gif|png)$# i");
// Store and send cookie-data like a browser does
$crawler->enableCookieHandling(true);
// Set the traffic-limit to 1 MB (in bytes,
// for testing we dont want to "suck" the whole site)
$crawler->setTrafficLimit(1000 * 1024);
$crawler->go();
foreach ($tab as $link ){
echo $link ;
}
?>
je pense que l'erreur au niveau de declaration du tableau
aide svp !