1
0
Fork 0
forked from blallo/rss-bridge

Merge pull request #290 from ORelio/master

[Numerama] Fix the fix by inlining subfunction
This commit is contained in:
Mitsu 2016-07-19 20:50:06 +02:00 committed by GitHub
commit a9e6f5514e

View file

@ -19,16 +19,8 @@ class NumeramaBridge extends BridgeAbstract{
return $string; return $string;
} }
function NumeramaExtractContent($bridge, $url) $feed = $this->getURI().'feed/';
{ $html = $this->file_get_html($feed) or $this->returnError('Could not request Numerama: '.$feed, 500);
$html2 = $bridge->file_get_html($url);
$text = $html2->find('section[class=related-article]', 0)->innertext = ''; // remove related articles block
$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
return $text;
}
$html = $this->file_get_html('http://www.numerama.com/feed/') or $this->returnError('Could not request Numerama.', 404);
$limit = 0; $limit = 0;
foreach($html->find('item') as $element) { foreach($html->find('item') as $element) {
@ -38,7 +30,14 @@ class NumeramaBridge extends BridgeAbstract{
$item->author = NumeramaStripCDATA($element->find('dc:creator', 0)->innertext); $item->author = NumeramaStripCDATA($element->find('dc:creator', 0)->innertext);
$item->uri = NumeramaStripCDATA($element->find('guid', 0)->plaintext); $item->uri = NumeramaStripCDATA($element->find('guid', 0)->plaintext);
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext); $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
$item->content = NumeramaExtractContent($this, $item->uri);
$article_url = NumeramaStripCDATA($element->find('guid', 0)->plaintext);
$article_html = $this->file_get_html($article_url) or $this->returnError('Could not request Numerama: '.$article_url, 500);
$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
$contents = $contents.$article_html->find('article[class=post-content]', 0)->innertext; // extract the post
$item->content = $contents;
$this->items[] = $item; $this->items[] = $item;
$limit++; $limit++;
} }