'Gagal mengambil data dari sumber']); exit; } libxml_use_internal_errors(true); $dom = new DOMDocument(); $dom->loadHTML($response); libxml_clear_errors(); $xpath = new DOMXPath($dom); $items = $xpath->query("//div[contains(@class, 'film_list-wrap')]/div"); $data = []; foreach ($items as $item) { $titleNode = $xpath->query(".//h3/a", $item)[0] ?? null; $imgNode = $xpath->query(".//img", $item)[0] ?? null; if ($titleNode && $imgNode) { $data[] = [ 'title' => trim($titleNode->nodeValue), 'link' => $titleNode->getAttribute('href'), 'image' => $imgNode->getAttribute('data-src'), ]; } } if (!empty($data)) { file_put_contents($cacheFile, json_encode($data, JSON_PRETTY_PRINT)); file_put_contents($logFile, "[".date("Y-m-d H:i:s")."] Update sukses: ".count($data)." data\n", FILE_APPEND); file_put_contents(__DIR__ . '/last_update.json', json_encode([ 'time' => date('Y-m-d H:i:s') ])); } header('Content-Type: application/json'); echo json_encode($data, JSON_PRETTY_PRINT);