diff --git a/bridges/NumeramaBridge.php b/bridges/NumeramaBridge.php index e1829c3..c8dcb4c 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++; }