Actualiser api.php
This commit is contained in:
@@ -116,7 +116,7 @@ function emptyPhysicalResult() {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── NOUVELLE FONCTION : SCRAPPING GO-UPC.COM (CORRIGÉE) ──
|
// ── NOUVELLE FONCTION : SCRAPPING GO-UPC.COM (MODIFIÉE) ──
|
||||||
function fetchFromGoUpc($ean) {
|
function fetchFromGoUpc($ean) {
|
||||||
$empty = emptyPhysicalResult();
|
$empty = emptyPhysicalResult();
|
||||||
$url = "https://go-upc.com/search?q=" . urlencode($ean);
|
$url = "https://go-upc.com/search?q=" . urlencode($ean);
|
||||||
@@ -132,6 +132,14 @@ function fetchFromGoUpc($ean) {
|
|||||||
$empty['title'] = $title;
|
$empty['title'] = $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ✅ RÉCUPÉRATION DE L'IMAGE DEPUIS GO-UPC
|
||||||
|
// Chercher dans les figures product-image
|
||||||
|
if (preg_match('/<figure[^>]*class="product-image[^"]*"[^>]*>.*?<img[^>]*src="([^"]+\.(?:jpg|jpeg|png|webp))"/is', $html, $m)) {
|
||||||
|
$empty['poster'] = trim($m[1]);
|
||||||
|
} elseif (preg_match('/<img[^>]*src="([^"]+go-upc\.s3\.amazonaws\.com[^"]+)"/i', $html, $m)) {
|
||||||
|
$empty['poster'] = trim($m[1]);
|
||||||
|
}
|
||||||
|
|
||||||
// ✅ NETTOYAGE DU TITRE
|
// ✅ NETTOYAGE DU TITRE
|
||||||
if (!empty($empty['title'])) {
|
if (!empty($empty['title'])) {
|
||||||
$empty['title'] = html_entity_decode($empty['title'], ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
$empty['title'] = html_entity_decode($empty['title'], ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||||
@@ -157,13 +165,6 @@ function fetchFromGoUpc($ean) {
|
|||||||
$empty['title'] = trim($empty['title']);
|
$empty['title'] = trim($empty['title']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ RÉCUPÉRATION DE L'IMAGE DEPUIS GO-UPC
|
|
||||||
if (preg_match('/<figure[^>]*class="product-image[^"]*"[^>]*>.*?<img[^>]*src="([^"]+\.(?:jpg|jpeg|png|webp))"/is', $html, $m)) {
|
|
||||||
$empty['poster'] = trim($m[1]);
|
|
||||||
} elseif (preg_match('/<img[^>]*src="([^"]+go-upc\.s3\.amazonaws\.com[^"]+)"/i', $html, $m)) {
|
|
||||||
$empty['poster'] = trim($m[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($empty['title'])) {
|
if (!empty($empty['title'])) {
|
||||||
$empty['format'] = detectFormat($empty['title']);
|
$empty['format'] = detectFormat($empty['title']);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user