Actualiser api.php
This commit is contained in:
@@ -564,15 +564,36 @@ switch ($action) {
|
|||||||
$title = $_GET['title'] ?? '';
|
$title = $_GET['title'] ?? '';
|
||||||
$year = $_GET['year'] ?? '';
|
$year = $_GET['year'] ?? '';
|
||||||
$format = $_GET['format'] ?? 'Blu-ray';
|
$format = $_GET['format'] ?? 'Blu-ray';
|
||||||
|
|
||||||
if (!$title) { echo json_encode(['error' => 'Titre manquant']); exit; }
|
if (!$title) { echo json_encode(['error' => 'Titre manquant']); exit; }
|
||||||
|
|
||||||
$result = ['title' => $title, 'year' => $year, 'format' => $format];
|
$ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
|
||||||
$data = fetchDVDCover($title, $year, $format);
|
$searchUrl = "https://www.dvdcover.com/?s=" . urlencode(cleanTitle($title));
|
||||||
$result['data'] = $data;
|
|
||||||
$result['status'] = $data ? 'OK' : 'AUCUN_RÉSULTAT';
|
|
||||||
|
|
||||||
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
$html = httpGet($searchUrl, 10, $ua);
|
||||||
|
|
||||||
|
$diag = [
|
||||||
|
'url' => $searchUrl,
|
||||||
|
'html_length' => $html ? strlen($html) : 0,
|
||||||
|
'html_snippet' => $html ? substr(strip_tags($html), 0, 500) : 'VIDE/ERREUR',
|
||||||
|
'cloudflare' => ($html && strpos($html, 'cloudflare') !== false) ? true : false,
|
||||||
|
'captcha' => ($html && strpos($html, 'captcha') !== false) ? true : false,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Cherche les articles si HTML reçu
|
||||||
|
if ($html) {
|
||||||
|
$dom = new DOMDocument();
|
||||||
|
@$dom->loadHTML($html);
|
||||||
|
$xpath = new DOMXPath($dom);
|
||||||
|
$links = $xpath->query('//article[contains(@class,"post")]//a/@href');
|
||||||
|
$diag['articles_found'] = $links->length;
|
||||||
|
|
||||||
|
// Essai avec d'autres sélecteurs courants
|
||||||
|
$diag['alt1_h2_links'] = $xpath->query('//h2//a/@href')->length;
|
||||||
|
$diag['alt2_figure_imgs'] = $xpath->query('//figure//img/@src')->length;
|
||||||
|
$diag['alt3_any_article'] = $xpath->query('//article')->length;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($diag, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||||
exit;
|
exit;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user