blob: 151484c45af5860b8f392a460b18013d3d6f2b5f (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<?php
class WeLiveSecurityBridge extends FeedExpander
{
const MAINTAINER = 'ORelio';
const NAME = 'We Live Security';
const URI = 'https://www.welivesecurity.com/';
const DESCRIPTION = 'Returns the newest articles.';
const PARAMETERS = [
[
'limit' => self::LIMIT,
],
];
protected function parseItem(array $item)
{
$html = getSimpleHTMLDOMCached($item['uri']);
if (!$html) {
$item['content'] .= '<br /><p><em>Could not request ' . $this->getName() . ': ' . $item['uri'] . '</em></p>';
return $item;
}
$html = $html->find('.article-page', 0);
$content_html = $html->find('.article-body', 0);
// Remove social media footer
foreach ($content_html->find('blockquote') as $blockquote) {
if (str_starts_with(trim($blockquote->plaintext), 'Connect with us on')) {
$blockquote->outertext = '';
}
}
// Headline subtitle
$content = $content_html->innertext;
$subtitle = $html->find('.sub-title', 0);
if ($subtitle) {
$content = '<p><b>' . $subtitle->plaintext . '</b></p>' . $content;
}
// Author
$author = $html->find('.article-author', 0);
if ($author && !isset($item['author'])) {
$item['author'] = trim($author->plaintext);
}
$item['content'] = trim($content);
return $item;
}
public function collectData()
{
$feed = static::URI . 'feed/';
$limit = $this->getInput('limit') ?? 10;
$this->collectExpandableDatas($feed, $limit);
}
}
|