rss-bridge/bridges/CommonDreamsBridge.php
Dag 936ae8cca3
various fixes (#3190)
* fix: Call to a member function parent() on null

* fix: notice

fixes Trying to get property plaintext of non-object at bridges/WikiLeaksBridge.php line 96

* fix: CommonDreamsBridge
2022-12-13 21:04:57 +01:00

31 lines
808 B
PHP

<?php
class CommonDreamsBridge extends FeedExpander
{
const MAINTAINER = 'nyutag';
const NAME = 'CommonDreams Bridge';
const URI = 'https://www.commondreams.org/';
const DESCRIPTION = 'Returns the newest articles.';
public function collectData()
{
$this->collectExpandableDatas('http://www.commondreams.org/rss.xml', 10);
}
protected function parseItem($newsItem)
{
$item = parent::parseItem($newsItem);
$item['content'] = $this->extractContent($item['uri']);
return $item;
}
private function extractContent($url)
{
$dom = getSimpleHTMLDOMCached($url);
$summary = $dom->find('div.node__body', 0);
$text = $summary->innertext;
$dom->clear();
unset($dom);
return $text;
}
}