1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-07-30 21:30:14 +02:00

refactor: FeedExpander::parseItem() descendants (#3744)

This commit is contained in:
Dag
2023-10-13 00:25:34 +02:00
committed by GitHub
parent 9bda9e246a
commit 382648fc22
46 changed files with 314 additions and 281 deletions

View File

@@ -10,26 +10,28 @@ class EngadgetBridge extends FeedExpander
public function collectData()
{
$url = 'https://www.engadget.com/rss.xml';
$max = 10;
$this->collectExpandableDatas(static::URI . 'rss.xml', $max);
$this->collectExpandableDatas($url, $max);
}
protected function parseItem($newsItem)
protected function parseItem($item)
{
$item = parent::parseItem($newsItem);
$url = (string) $newsItem->link;
if (!$url) {
$item = parent::parseItem($item);
$itemUrl = trim($item['uri']);
if (!$itemUrl) {
return $item;
}
// todo: remove querystring tracking
$articlePage = getSimpleHTMLDOM($url);
$dom = getSimpleHTMLDOM($itemUrl);
// figure contain's the main article image
$article = $articlePage->find('figure', 0);
$article = $dom->find('figure', 0);
// .article-text has the actual article
foreach ($articlePage->find('.article-text') as $element) {
foreach ($dom->find('.article-text') as $element) {
$article = $article . $element;
}
$item['content'] = $article;
$item['content'] = $article ?? '';
return $item;
}
}