Add GoAccessBridge (#3422)

This commit is contained in:
Simon Alberny 2023-06-07 22:36:21 +02:00 committed by GitHub
parent 6fa1f349d9
commit 08be0ad7a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 0 deletions

View File

@ -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;
}
}
}