';
foreach ($tableRows as $row) {
echo '
';
echo '
' . $row['name'] . '' . $row['category'];
// Initialize cURL
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $row['nameUrl']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3');
$response = curl_exec($curl);
if ($response === false) {
die('Error: ' . curl_error($curl));
}
$startPos = strpos($response, '
');
$endPos = strpos($response, '
');
if ($startPos !== false) {
$content = substr($response, $startPos, $endPos - $startPos);
$content = preg_replace_callback('/(]+src=")([^"]+)("[^>]*>)/i', function ($matches) {
$imageUrl = $matches[2];
$imageData = base64_encode(file_get_contents($imageUrl));
return $matches[1] . 'data:image/png;base64,' . $imageData . $matches[3];
}, $content);
echo '' . $content . '
';
} else {
$fallbackStartPos = strpos($response, '');
$fallbackEndPos = strpos($response, '
', $fallbackStartPos);
if ($fallbackStartPos !== false && $fallbackEndPos !== false) {
$fallbackContent = substr($response, $fallbackStartPos, $fallbackEndPos - $fallbackStartPos + 8);
$fallbackContent = preg_replace_callback('/(]+src=")([^"]+)("[^>]*>)/i', function ($matches) {
$imageUrl = $matches[2];
$imageData = base64_encode(file_get_contents($imageUrl));
return $matches[1] . 'data:image/png;base64,' . $imageData . $matches[3];
}, $fallbackContent);
echo '' . $fallbackContent . '
';
}
}
curl_close($curl);
echo '';
}
echo '';
} else {
echo 'No table found.';
}
}
?>