blob: 94874496e8a714f4464f2012c95d5d2a569d66a1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
}
}
}
|