fix: quickfix for heise, #3118 (#3119)

This commit is contained in:
Dag 2022-10-27 19:59:45 +02:00 committed by GitHub
parent 52af2ae34c
commit 314d4c7a3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 12 deletions

View File

@ -80,22 +80,25 @@ class HeiseBridge extends FeedExpander
$article = str_get_html($article->outertext); $article = str_get_html($article->outertext);
$header = $article->find('header.a-article-header', 0); $header = $article->find('header.a-article-header', 0);
$headerElements = $header->find('p, a-img img, figure img'); if ($header) {
$item['content'] = implode('', $headerElements); $headerElements = $header->find('p, a-img img, figure img');
$item['content'] = implode('', $headerElements);
$authors = $header->find('.a-creator__names .a-creator__name'); $authors = $header->find('.a-creator__names .a-creator__name');
if ($authors) { if ($authors) {
$item['author'] = implode(', ', array_map(function ($e) { $item['author'] = implode(', ', array_map(function ($e) {
return $e->plaintext; return $e->plaintext;
}, $authors)); }, $authors));
}
} }
$content = $article->find('.article-content', 0); $content = $article->find('.article-content', 0);
$contentElements = $content->find( if ($content) {
'p, h3, ul, table, pre, a-img img, a-bilderstrecke h2, a-bilderstrecke figure, a-bilderstrecke figcaption' $contentElements = $content->find(
); 'p, h3, ul, table, pre, a-img img, a-bilderstrecke h2, a-bilderstrecke figure, a-bilderstrecke figcaption'
$item['content'] .= implode('', $contentElements); );
$item['content'] .= implode('', $contentElements);
}
foreach ($article->find('a-img img, a-bilderstrecke img, figure img') as $img) { foreach ($article->find('a-img img, a-bilderstrecke img, figure img') as $img) {
$item['enclosures'][] = $img->src; $item['enclosures'][] = $img->src;
} }