2016-07-19 20:37:33 +03:00
|
|
|
<?php
|
2016-09-14 14:33:38 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
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,
|
|
|
|
],
|
|
|
|
];
|
2016-09-14 14:33:38 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
protected function parseItem($item)
|
|
|
|
{
|
|
|
|
$item = parent::parseItem($item);
|
2016-09-14 14:33:38 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$article_html = getSimpleHTMLDOMCached($item['uri']);
|
|
|
|
if (!$article_html) {
|
|
|
|
$item['content'] .= '<p><em>Could not request ' . $this->getName() . ': ' . $item['uri'] . '</em></p>';
|
|
|
|
return $item;
|
|
|
|
}
|
2016-09-14 14:33:38 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$article_content = $article_html->find('div.formatted', 0)->innertext;
|
|
|
|
$article_content = stripWithDelimiters($article_content, '<script', '</script>');
|
|
|
|
$article_content = stripRecursiveHTMLSection($article_content, 'div', '<div class="comments');
|
|
|
|
$article_content = stripRecursiveHTMLSection($article_content, 'div', '<div class="similar-articles');
|
|
|
|
$article_content = stripRecursiveHTMLSection($article_content, 'span', '<span class="meta');
|
|
|
|
$item['content'] = trim($article_content);
|
2016-09-14 14:33:38 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
return $item;
|
|
|
|
}
|
2016-09-14 14:33:38 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$feed = static::URI . 'feed/';
|
|
|
|
$limit = $this->getInput('limit') ?? 10;
|
|
|
|
$this->collectExpandableDatas($feed, $limit);
|
|
|
|
}
|
2016-08-09 15:57:42 +03:00
|
|
|
}
|