aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dennis <Dennis.mellegaard@gmail.com> 2024-11-04 15:16:58 +0100
committerGravatar GitHub <noreply@github.com> 2024-11-04 15:16:58 +0100
commitdd165ea9d1d2306f96188943fc7441d55f4cc1e4 (patch)
tree6d0ba7be0f395e19699449d7091f6815f9c37bd3
parent1cd5b072f37a6cab9b183f732338e623eeadb612 (diff)
downloadrss-bridge-dd165ea9d1d2306f96188943fc7441d55f4cc1e4.tar.gz
rss-bridge-dd165ea9d1d2306f96188943fc7441d55f4cc1e4.tar.zst
rss-bridge-dd165ea9d1d2306f96188943fc7441d55f4cc1e4.zip
[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
-rw-r--r--bridges/HuntShowdownNewsBridge.php40
1 files changed, 40 insertions, 0 deletions
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 @@
+<?php
+
+class HuntShowdownNewsBridge extends BridgeAbstract
+{
+ const NAME = 'Hunt Showdown News Bridge';
+ const MAINTAINER = 'deffy92';
+ const URI = 'https://www.huntshowdown.com';
+ const DESCRIPTION = 'Returns the latest news from HuntShowdown.com/news';
+ const BASE_URI = 'https://www.huntshowdown.com/';
+
+ public function collectData()
+ {
+ $html = getSimpleHTMLDOM('https://www.huntshowdown.com/news/tagged/news');
+ $articles = defaultLinkTo($html, self::URI)->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 = '<img src="' . $article_cover . '" alt="' . $article_title . '"> <br/> <br/>';
+ $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