1
0
Fork 0
SabradouMap/index.php

58 lines
1.6 KiB
PHP

<?php
// URL de la page à analyser
$url = 'https://www.sabradou.com/index.php';
// Récupération du contenu de la page
$html = file_get_contents($url);
// Création d'un objet DOMDocument
$dom = new DOMDocument();
libxml_use_internal_errors(true); // Ignore les erreurs de parsing HTML
$dom->loadHTML($html);
libxml_clear_errors();
// Recherche de la div avec l'id "calendrier"
$calendrierDiv = $dom->getElementById('calendrier');
// Récupération des liens dans la liste
$calendrierLinks = $calendrierDiv->getElementsByTagName('a');
// Tableau pour stocker les nodes et les URLs
$calendrier = array();
// Parcourir les liens et récupérer les nodes et les URLs
foreach ($calendrierLinks as $link) {
$node = $link->nodeValue;
$url = $link->getAttribute('href');
$calendrier[] = array(
'node' => $node,
'url' => 'https://www.sabradou.com/' . $url
);
}
// Afficher le tableau $calendrier
// foreach ($calendrier as $item) {
// echo "Node : " . $item['node'] . "<br />";
// echo "URL : " . $item['url'] . "<br />";
// }
?>
<!DOCTYPE html>
<html>
<head>
<title>Formulaire de sélection</title>
</head>
<body>
<form action="map.php" method="POST">
<label for="calendrier-list">Sélectionnez un élément :</label>
<select name="calendrier" id="calendrier-list">
<?php foreach ($calendrier as $item) : ?>
<option value="<?php echo $item['url']; ?>"><?php echo $item['node']; ?></option>
<?php endforeach; ?>
</select>
<br>
<input type="submit" value="Afficher sur la carte">
</form>
</body>
</html>