j'écrit un script pour parser les pages web afin d'afficher tous les liens existants :
j'ai utilisé la classe DOMDocument
voilà mon script:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php 
 
// It may take a whils to spider a website ... 
   set_time_limit(10000); 
 
// Inculde the phpcrawl-mainclass 
include_once('../PHPCrawl_083/PHPCrawl_083/libs/PHPCrawler.class.php'); 
 //include ('2.php');  
// Extend the class and override the handleDocumentInfo()-method 
 
class MyCrawler extends PHPCrawler 
 
{   
function handleDocumentInfo(PHPCrawlerDocumentInfo $DocInfo) {
 
    if (PHP_SAPI == "cli") $lb = "\n"; 
    else {
	$lb = "<br />"; 
 
     $home_url = parse_url($DocInfo->url ,PHP_URL_HOST ); 
 
    $dom = new DOMDocument();
  $dom->loadHTML($DocInfo->url);
$links = $dom->getElementsByTagName('a');
foreach($links as $link) {
 
 echo  $link->getAttribute('href').''.$link->nodeValue. PHP_EOL;
 
}   
   }
 }
}
$crawler = new MyCrawler(); 
$crawler->setURL("http://smart-techno.org"); 
 
$crawler->addURLFilterRule("#\.(jpg|gif|png|pdf|jpeg|css|js)$#i"); 
$crawler->setWorkingDirectory("C:/Users/mayss/Documents/travailcrawl/"); 
$crawler->go(); 
//httpwww.annuaire-ag.com
//
 
?>
mais ça n'affiche rien , je ne sais pa d'ou vient l'erreur !!!