mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-27 03:50:42 +03:00
3bacb407fe
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
29 lines
1.1 KiB
PHP
29 lines
1.1 KiB
PHP
<?php
|
|
class NumeramaBridge extends FeedExpander {
|
|
|
|
const MAINTAINER = 'mitsukarenai';
|
|
const NAME = 'Numerama';
|
|
const URI = 'http://www.numerama.com/';
|
|
const DESCRIPTION = 'Returns the 5 newest posts from Numerama (full text)';
|
|
|
|
public function collectData(){
|
|
$this->collectExpandableDatas(self::URI . 'feed/', 5);
|
|
}
|
|
|
|
protected function parseItem($newsItem){
|
|
$item = parent::parseItem($newsItem);
|
|
$item['content'] = $this->ExtractContent($item['uri']);
|
|
return $item;
|
|
}
|
|
|
|
private function ExtractContent($url){
|
|
$article_html = $this->getSimpleHTMLDOMCached('Could not request Numerama: '.$url);
|
|
$contents = $article_html->find('section[class=related-article]', 0)->innertext = ''; // remove related articles block
|
|
$contents = '<img alt="" style="max-width:300px;" src="'.$article_html->find('meta[property=og:image]', 0)->getAttribute('content').'">'; // add post picture
|
|
return $contents . $article_html->find('article[class=post-content]', 0)->innertext; // extract the post
|
|
}
|
|
|
|
public function getCacheDuration() {
|
|
return 1800; // 30min
|
|
}
|
|
}
|