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
|
<?php
function recupurlville($url)
{
$curl=curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
$contenu=curl_exec($curl);
$RegEx = '#<[aA](\s)*(href|HREF)(\s)*=(\s)*[\"|\'](.*?)[\"|\'](.*?)>#is';
preg_match_all($RegEx,$contenu,$Results,PREG_PATTERN_ORDER);
$tableaux=array_unique($Results[5]);
foreach ($tableaux as $Link)
{
if (ereg('/',$Link))
{
if (!ereg('http://',$Link))
{
if(ereg('mairie-',$Link) or ereg('ville-',$Link) /* or ereg('region-',$Link) or ereg('departement-',$Link)*/)
{
if(ereg('ville-',$Link))
{
scanurl("lenomdudomaine$Link");
echo "<hr />";
ajoutdanstxt($Link);
}
if(ereg('mairie-',$Link))
{
scanurl("lenomdudomaine$Link");
echo "<hr />";
ajoutdanstxt($Link);
}
}
}
}
}
}
function ajoutdanstxt($Link)
{
$file = 'texte.txt';
// Ouvre un fichier pour lire un contenu existant
$current = file_get_contents($file);
// Ajoute une personne
$current .= "http://lenomdudomaine$Link\n";
// Écrit le résultat dans le fichier
file_put_contents($file, $current);
}
recupurlville("lenomdudomaine/departement-hautes-pyrenees.html");
?> |
Partager