From dd165ea9d1d2306f96188943fc7441d55f4cc1e4 Mon Sep 17 00:00:00 2001 From: Dennis Date: Mon, 4 Nov 2024 15:16:58 +0100 Subject: [PATCH] [HuntShowdownNewsBridge] Fetches the latest articles from Hunt Showdown (#4318) * feat: add Hunt Showdown News Bridge for fetching latest news articles * chore: clean up formatting and remove unnecessary whitespace in HuntShowdownNewsBridge.php --- bridges/HuntShowdownNewsBridge.php | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 bridges/HuntShowdownNewsBridge.php diff --git a/bridges/HuntShowdownNewsBridge.php b/bridges/HuntShowdownNewsBridge.php new file mode 100644 index 00000000..6aca88f7 --- /dev/null +++ b/bridges/HuntShowdownNewsBridge.php @@ -0,0 +1,40 @@ +find('.col'); + + // Removing first element because it's a "load more" button + array_shift($articles); + foreach ($articles as $article) { + $item = []; + + $article_title = $article->find('h3', 0)->plaintext; + $article_content = $article->find('p', 0)->plaintext; + $article_cover = $article->find('img', 0)->src; + + // If there is a cover, add it to the content + if (!empty($article_cover)) { + $article_cover = '' . $article_title . '

'; + $article_content = $article_cover . $article_content; + } + + $item['uri'] = $article->find('a', 0)->href; + $item['title'] = $article_title; + $item['content'] = $article_content; + $item['enclosures'] = [$article_cover]; + $item['timestamp'] = $article->find('span', 0)->plaintext; + + $this->items[] = $item; + } + } +} \ No newline at end of file