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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
<html>
<head>
<title>Lire un source HTML</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h3 align="center"><i><b>Lire un source HTML</b></i> </h3>
<form method="post" action="">
<div align="center">URL
<input type="text" name="url">
<input type="submit" name="lire" value="Lire">
</div>
</form>
<hr width="70%" align="center">
<?
if (strlen($url)!=0)
{
echo "<h3 align=\"center\"><i>URL passée : $url</i></h3>";
echo "<hr width=\"100%\" align=\"center\">";
// Ajout de http:// si cela a été omis, substr() :Retourne un segment de chaîne
if (substr($url,0,7)!='http://')
{
$url='http://'.$url;
}
$fp = fopen ($url,"r"); //lecture da la page
while (!feof($fp)) //parcours des lignes
{
$page .= fgets($fp,4096); //lecture contenu ligne
}
echo "<h3 align=\"center\"><i>En-tête de la page</i></h3>";
//Titre de la page
echo "<h4><i>Titre :</i></h4>";
$titre = eregi ("<title>(.*)</title>",$page,$regs); //isole le titre
echo $regs[1]; //renvoie toute la chaine
//Extraction de toutes les balises méta d'un fichier HTML dans un tableau
$tabMeta = get_meta_tags($url);
//Balise meta description : Description détaillée du site
echo "<h4><i>Balise meta description :</i></h4>";
echo $tabMeta["description"]."<br>";
//Balise meta keyword : Liste de mots clés
echo "<h4><i>Balise meta keyword :</i></h4>";
echo $tabMeta["keywords"]."<br>";
echo "<hr width=\"100%\" align=\"center\">";
fclose($fp); //fermeture de la page
}
?>
</body>
</html> |
Partager