2014-05-26 02:30:46 +04:00
|
|
|
<?php
|
2016-09-05 19:43:56 +03:00
|
|
|
class NumeramaBridge extends FeedExpander {
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const MAINTAINER = 'mitsukarenai';
|
|
|
|
const NAME = 'Numerama';
|
|
|
|
const URI = 'http://www.numerama.com/';
|
|
|
|
const DESCRIPTION = 'Returns the 5 newest posts from Numerama (full text)';
|
2015-10-12 18:13:27 +03:00
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
2016-09-05 21:26:45 +03:00
|
|
|
$this->collectExpandableDatas(self::URI . 'feed/', 5);
|
2016-09-05 19:43:56 +03:00
|
|
|
}
|
2016-07-19 20:35:43 +03:00
|
|
|
|
2016-09-05 19:43:56 +03:00
|
|
|
protected function parseItem($newsItem){
|
2016-09-12 11:42:27 +03:00
|
|
|
$item = parent::parseItem($newsItem);
|
2016-09-05 19:43:56 +03:00
|
|
|
$item['content'] = $this->ExtractContent($item['uri']);
|
|
|
|
return $item;
|
|
|
|
}
|
2016-08-28 21:07:56 +03:00
|
|
|
|
2016-09-05 19:43:56 +03:00
|
|
|
private function ExtractContent($url){
|
2016-09-10 20:11:09 +03:00
|
|
|
$article_html = $this->getSimpleHTMLDOMCached('Could not request Numerama: '.$url);
|
2016-09-05 19:43:56 +03:00
|
|
|
$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
|
2014-05-26 02:30:46 +04:00
|
|
|
}
|
|
|
|
|
2016-07-19 20:35:43 +03:00
|
|
|
public function getCacheDuration() {
|
2014-05-26 02:30:46 +04:00
|
|
|
return 1800; // 30min
|
|
|
|
}
|
|
|
|
}
|