Exemplo n.º 1
0
    }
}
class Snatch extends SiteScraper
{
    function getArticle($keyword)
    {
        $keyword = str_replace(" ", "+", $keyword);
        $article = $this->makeArticle("http://www.google.com/cse?cx=partner-pub-2050911826501646%3A1m6ue6-c897&cof=FORID%3A10&ie=ISO-8859-1&q={$keyword}&sa=Search&siteurl=www.articlesnatch.com%2F&ad=w9&num=10&rurl=http%3A%2F%2Fwww.articlesnatch.com%2Fcse.php%3Fcx%3Dpartner-pub-2050911826501646%253A1m6ue6-c897%26cof%3DFORID%253A10%26ie%3DISO-8859-1%26q%3Dcats%26sa%3DSearch%26siteurl%3Dwww.articlesnatch.com%252F%26siteurl%3Dwww.articlesnatch.com%252F", 'div[class=articletext]');
        $article = $this->stripJS($article);
        return $article;
    }
}
class ABase extends SiteScraper
{
    function makeSearchLink($articleUrl)
    {
        $htmlContents = $this->getHtml($articleUrl);
        $links = $this->getAllLinks($htmlContents);
        $links = array_filter($links, array($this, 'endsWithHtml'));
        return $links[array_rand($links)];
    }
    function getArticle($keyword)
    {
        $keyword = str_replace(" ", "+", $keyword);
        $article = $this->makeArticle("http://www.articlesbase.com/find-articles.php?q={$keyword}", 'div[class=article_cnt KonaBody]');
        return $article;
    }
}
$n = new ABase();
print_r($n->getArticle("pink floyd"));