From 08be0ad7a57f723ae2aab64b537d91db535fbf81 Mon Sep 17 00:00:00 2001 From: Simon Alberny <contact@simounet.net> Date: Wed, 7 Jun 2023 22:36:21 +0200 Subject: [PATCH] Add GoAccessBridge (#3422) --- bridges/GoAccessBridge.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 bridges/GoAccessBridge.php diff --git a/bridges/GoAccessBridge.php b/bridges/GoAccessBridge.php new file mode 100644 index 00000000..94874496 --- /dev/null +++ b/bridges/GoAccessBridge.php @@ -0,0 +1,38 @@ +<?php + +class GoAccessBridge extends BridgeAbstract +{ + const MAINTAINER = 'Simounet'; + const NAME = 'GoAccess'; + const URI_BASE = 'https://goaccess.io'; + const URI = self::URI_BASE . '/release-notes'; + const CACHE_TIMEOUT = 21600; //6h + const DESCRIPTION = 'GoAccess releases.'; + + public function collectData() + { + $html = getSimpleHTMLDOM(self::URI); + + $container = $html->find('.container.content', 0); + foreach ($container->find('div') as $element) { + $titleEl = $element->find('h2', 0); + $dateEl = $titleEl->find('small', 0); + $date = trim($dateEl->plaintext); + $title = is_object($titleEl) ? str_replace($date, '', $titleEl->plaintext) : ''; + $linkEl = $titleEl->find('a', 0); + $link = is_object($linkEl) ? $linkEl->href : ''; + $postUrl = self::URI . $link; + + $contentEl = $element->find('.dl-horizontal', 0); + $content = '<dl>' . $contentEl->xmltext() . '</dl>'; + + $item = []; + $item['uri'] = $postUrl; + $item['timestamp'] = strtotime($date); + $item['title'] = $title; + $item['content'] = $content; + + $this->items[] = $item; + } + } +}