<?php
class AgenceSciencePresseBridge extends FeedExpander {

	const MAINTAINER = 'Yan';
	const NAME = 'Agence Science Presse Bridge';
	const URI = 'https://www.sciencepresse.qc.ca/';
	const DESCRIPTION = 'Returns the newest articles.';

	protected function parseItem($item){
		$item = parent::parseItem($item);

		$article_html = getSimpleHTMLDOMCached($item['uri']);
		if(!$article_html) {
			$item['content'] = 'Could not request Agence Science Presse : ' . $item['uri'];
			return $item;
		}

		$article_content = '';
        $article_content .= str_replace(
			'src="/', 'src="' . self::URI,
			$article_html->find('main article', 0)->innertext
		);
		
		$article_content = stripWithDelimiters($article_content, '<script', '</script>');

		$item['content'] = $article_content;

		return $item;
	}

	public function collectData(){
		$feedUrl = self::URI . '/rss.xml';
		$this->collectExpandableDatas($feedUrl);
	}
}
