function imprimirPosts($redditPosts) { foreach ($redditPosts as $post) { echo "---------------------------------------" . "\n"; //echo "id: ".$post->getAttribute('id')."\n"; echo "subrredit: " . $post->getAttribute('data-subreddit') . "\n"; echo "author: " . $post->getAttribute('data-author') . "\n"; echo "rank: " . $post->firstChild->nextSibling->nodeValue . "\n"; echo "score: " . obterFilhoPeloValorDoAtributoClass($post, "midcol unvoted")->firstChild->nextSibling->nextSibling->nodeValue . "\n"; echo "link: " . $post->getElementsByTagName('a')->item(0)->getAttribute('href') . "\n"; echo "---------------------------------------"; } }
function postToString($post) { $link = $post->getElementsByTagName('a')->item(0)->getAttribute('href') . ">Link"; //$post->getElementsByTagName('a')->item(0)->getAttribute('href'); $link2 = $post->getElementsByTagName('a')->item(0)->getAttribute('href'); return $ret = "<center><font size=" . '8' . "<b><u></u></b> " . obterFilhoPeloValorDoAtributoClass($post, "entry unvoted")->firstChild->firstChild->nodeValue . "</br></font><center>" . criarVideoYoutube($link2) . criarImagens($link2) . "<p><b>Link</b>: " . "<a href=" . $link . "</a>" . "</br>" . "<b>Subrredit</b>: " . $post->getAttribute('data-subreddit') . "</br>" . "<b>Author</b>: " . $post->getAttribute('data-author') . "</br>" . "<b>Rank</b>: " . $post->firstChild->nextSibling->nodeValue . "</br>" . "<b>Score</b>: " . obterFilhoPeloValorDoAtributoClass($post, "midcol unvoted")->firstChild->nextSibling->nextSibling->nodeValue . "</br>"; }