[Numerama] update bridge post extraction (issue #158)

This commit is contained in:
Mitsukarenai 2015-10-12 17:13:27 +02:00
parent f11d6fc2ad
commit 01d6859f77

View file

@ -2,12 +2,12 @@
/** /**
* RssBridgeNumerama * RssBridgeNumerama
* Returns the 5 newest posts from http://www.numerama.com (full text) * Returns the 5 newest posts from http://www.numerama.com (full text)
* 2014-05-25
* *
* @name Numerama * @name Numerama
* @homepage http://www.numerama.com/ * @homepage http://www.numerama.com/
* @description Returns the 5 newest posts from Numerama (full text) * @description Returns the 5 newest posts from Numerama (full text)
* @maintainer mitsukarenai * @maintainer mitsukarenai
* @update 2015-10-12
*/ */
class NumeramaBridge extends BridgeAbstract{ class NumeramaBridge extends BridgeAbstract{
@ -18,14 +18,17 @@ class NumeramaBridge extends BridgeAbstract{
$string = str_replace(']]>', '', $string); $string = str_replace(']]>', '', $string);
return $string; return $string;
} }
function NumeramaExtractContent($url) {
$html2 = file_get_html($url); function NumeramaExtractContent($url)
$text = $html2->find('h2.intro', 0)->innertext; {
$text = $text.$html2->find('div.content', 0)->innertext; $html2 = file_get_html($url);
$text = strip_tags($text, '<p><b><a><blockquote><img><em><ul><ol>'); $text = $html2->find('section[class=related-article]', 0)->innertext = ''; // remove related articles block
return $text; $text = '<img alt="" style="max-width:300px;" src="'.$html2->find('meta[property=og:image]', 0)->getAttribute('content').'">'; // add post picture
} $text = $text.$html2->find('article[class=post-content]', 0)->innertext; // extract the post
$html = file_get_html('http://www.numerama.com/rss/news.rss') or $this->returnError('Could not request Numerama.', 404); return $text;
}
$html = file_get_html('http://www.numerama.com/rss/news.rss') or $this->returnError('Could not request Numerama.', 404);
$limit = 0; $limit = 0;
foreach($html->find('item') as $element) { foreach($html->find('item') as $element) {