RSS if (!preg_match('/^20[0-9]{2}-[0-9]+(DC|QPC)$/', $_GET["num"])) { echo 'Bad param'; die(); } header('content-type: application/rss+xml; charset=utf-8'); // Contourner protection anti-robots basique $opts = [ 'http' => [ 'header' => "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0\r\n" . "Upgrade-Insecure-Requests: 1" . "Cookie: foo=bar", ] ]; $context = stream_context_create($opts); $response = file_get_contents('https://www.conseil-constitutionnel.fr/recherche-experte/resultats?champ_recherche[decision]=decision&text='.$_GET['num'], false, $context); $response = mb_convert_encoding($response, 'HTML-ENTITIES', "UTF-8"); $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($response); $xpath = new DOMXpath($dom); $elements = $xpath->query('//article//a[@rel="bookmark"]'); echo ' CC - '.$_GET["num"].' https://www.conseil-constitutionnel.fr/ CC - '.$_GET["num"].''.PHP_EOL.PHP_EOL; foreach ($elements as $item) { preg_match('/[A-Z0-9]+(?=\.htm)/', $item->getAttribute("href"), $matches); echo ' <![CDATA['.$item->getAttribute("title").']]> '.$item->getAttribute("href").' getAttribute("title").']]> '.$matches[0].' '.PHP_EOL; } echo ' '; ?>