forked from blallo/rss-bridge
Merge pull request #290 from ORelio/master
[Numerama] Fix the fix by inlining subfunction
This commit is contained in:
commit
a9e6f5514e
1 changed files with 10 additions and 11 deletions
|
@ -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 = '<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);
|
||||
$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 = '<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;
|
||||
$limit++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue