summaryrefslogtreecommitdiff
path: root/bridges/CommonDreamsBridge.php
blob: 22b9238d2bbd5f22b9cdc205b39b5493ffb9bada (plain)
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
<?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){
		$html3 = getSimpleHTMLDOMCached($url);
		$text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext;
		$html3->clear();
		unset ($html3);
		return $text;
	}
}