[
'name' => 'Kategorie',
'type' => 'list',
'required' => true,
'values' => [
'Bayern' => 'bayern',
'Deutschland' => 'deutschland',
'Welt' => 'welt',
'Sport' => 'sport',
'Stars' => 'stars',
'Eilmeldungen' => 'eilmeldungen'
]
]
]
];
public function getIcon()
{
return 'https://www.google.com/s2/favicons?domain=www.antenne.de&sz=32';
}
public function collectData()
{
$category = $this->getInput('category');
$url = 'https://www.antenne.de/nachrichten/' . $category . '/';
$html = getSimpleHTMLDOM($url);
if (!$html) {
throw new \Exception('Konnte die Antenne Bayern Nachrichten-Seite nicht laden: ' . $url);
}
// Finde alle l-cardgrid__items Container
$cardGrids = $html->find('.l-cardgrid__items');
if (empty($cardGrids)) {
throw new \Exception('Keine Artikel-Container gefunden auf der Seite');
}
// Iteriere durch alle Cardgrid-Container
foreach ($cardGrids as $cardGrid) {
// Finde alle Artikel-Items in diesem Container
$articleItems = $cardGrid->find('.l-cardgrid__item');
foreach ($articleItems as $articleItem) {
$newsItem = $articleItem->find('.c-card', 0);
if (!$newsItem) {
continue;
}
$item = [];
// Link extrahieren
$link = $newsItem->find('a.u-faux-block-link-overlay', 0);
if (!$link) {
continue;
}
$item['uri'] = $link->href;
if (strpos($item['uri'], 'http') !== 0) {
$item['uri'] = self::URI . ltrim($item['uri'], '/');
}
// Titel aus h3
$titleElement = $newsItem->find('h3.o-headline', 0);
if ($titleElement) {
$item['title'] = trim($titleElement->plaintext);
} else {
continue; // Überspringe Artikel ohne Titel
}
// Bild extrahieren
$image = $newsItem->find('figure.c-image img', 0);
$imageUrl = null;
if ($image) {
// Versuche verschiedene Bild-Attribute
if (isset($image->src) && !empty($image->src) && strpos($image->src, 'data:image') !== 0) {
$imageUrl = $image->src;
} elseif (isset($image->{'data-src'}) && !empty($image->{'data-src'})) {
$imageUrl = $image->{'data-src'};
}
if ($imageUrl) {
// Stelle sicher, dass die URL absolut ist
if (strpos($imageUrl, 'http') !== 0) {
$imageUrl = self::URI . ltrim($imageUrl, '/');
}
$item['enclosures'] = [$imageUrl];
}
}
// Beschreibung extrahieren
$description = $newsItem->find('p.c-card__text', 0);
if ($description) {
$descriptionText = trim($description->plaintext);
// Content zusammenbauen: Bild + Beschreibung
$content = '';
if ($imageUrl) {
$content .= '
';
}
$content .= '
' . htmlspecialchars($descriptionText) . '
'; $item['content'] = $content; } elseif ($imageUrl) { // Nur Bild, wenn keine Beschreibung vorhanden $item['content'] = '