From 3a69573b27ccb4587f661a6cff0d9dc69a7f5456 Mon Sep 17 00:00:00 2001 From: ORelio Date: Tue, 19 Jul 2016 20:12:00 +0200 Subject: [PATCH] [Numerama] Fix the fix by inlinig subfunction Tested, this time ^^" + change errcodes from 404 to 500 --- bridges/NumeramaBridge.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/bridges/NumeramaBridge.php b/bridges/NumeramaBridge.php index e1829c31..c8dcb4cc 100644 --- a/bridges/NumeramaBridge.php +++ b/bridges/NumeramaBridge.php @@ -19,16 +19,8 @@ class NumeramaBridge extends BridgeAbstract{ return $string; } - function NumeramaExtractContent($bridge, $url) - { - $html2 = $bridge->file_get_html($url); - $text = $html2->find('section[class=related-article]', 0)->innertext = ''; // remove related articles block - $text = ''; // 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); + $feed = $this->getURI().'feed/'; + $html = $this->file_get_html($feed) or $this->returnError('Could not request Numerama: '.$feed, 500); $limit = 0; foreach($html->find('item') as $element) { @@ -38,7 +30,14 @@ class NumeramaBridge extends BridgeAbstract{ $item->author = NumeramaStripCDATA($element->find('dc:creator', 0)->innertext); $item->uri = NumeramaStripCDATA($element->find('guid', 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 = ''; // add post picture + $contents = $contents.$article_html->find('article[class=post-content]', 0)->innertext; // extract the post + + $item->content = $contents; $this->items[] = $item; $limit++; }