rss-bridge/bridges/CommonDreamsBridge.php

32 lines
808 B
PHP
Raw Normal View History

2015-04-26 20:22:20 +03:00
<?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;
}
2015-04-26 20:22:20 +03:00
}