From f9801a5c58148879a6b5ebdab3115bc3494e4341 Mon Sep 17 00:00:00 2001 From: Dag Date: Tue, 12 Apr 2022 23:37:05 +0200 Subject: [PATCH] [RoadAndTrack] fix: broken css selectors (#2642) --- bridges/RoadAndTrackBridge.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/bridges/RoadAndTrackBridge.php b/bridges/RoadAndTrackBridge.php index 22ec8b52..b81b45c2 100644 --- a/bridges/RoadAndTrackBridge.php +++ b/bridges/RoadAndTrackBridge.php @@ -1,4 +1,5 @@ find('.custom-promo-title', 0)->href; - $this->items[] = $this->fetchArticle($firstArticleLink); + $limit = 5; - $limit = 19; - foreach($page->find('.full-item-title') as $article) { + foreach($page->find('a.enk2x9t2') as $article) { $this->items[] = $this->fetchArticle($article->href); - $limit -= 1; - if($limit == 0) break; - } + if (count($this->items) >= $limit) { + break; + } + } } private function fixImages($content) { @@ -36,7 +35,6 @@ class RoadAndTrackBridge extends BridgeAbstract { } return $enclosures; - } private function fetchArticle($articleLink) { @@ -45,13 +43,19 @@ class RoadAndTrackBridge extends BridgeAbstract { $article = getSimpleHTMLDOM($articleLink); $item = array(); - $item['title'] = $article->find('.content-hed', 0)->innertext; + $title = $article->find('.content-hed', 0); + if ($title) { + $item['title'] = $title->innertext; + } + $item['author'] = $article->find('.byline-name', 0)->innertext; $item['timestamp'] = strtotime($article->find('.content-info-date', 0)->getAttribute('datetime')); $content = $article->find('.content-container', 0); - if($content->find('.content-rail', 0) !== null) + if($content->find('.content-rail', 0) !== null) { $content->find('.content-rail', 0)->innertext = ''; + } + $enclosures = $this->fixImages($content); $item['enclosures'] = $enclosures;