0

私は、bbc.co.uk/news/ Web サイトから最も人気のあるセクションを WordPress プラグインにスクレイピングしようとしています。現在、次のコードがあります。

<?php 
/*
    Plugin Name: BBC Scrape
    Description: Reprints the BBCs Most popular stories 
Author: The Health Check Team
    Version: 0.1-alpha
 */

include('simple_html_dom.php');        
$articles = array();  
getArticles('http://www.bbc.co.uk/news/');      
function getArticles($page) {  
    global $articles;  
  <br>
    $html = new simple_html_dom();  
    $html->load_file($page);  

$items = $html->find('div[class=livestats livestats-tabbed tabbed most-popular]');    

foreach($items as $post) {  
    # remember comments count as nodes  
    $articles[] = array($post->children(3)->outertext,  
                        $post->children(4)->first_child()->outertext,  
            $post->children(5)->first_child()->outertext);  
} 

}
?>

以前に などの関数を使用wp_remote_getしたことがありますが、それはサイト全体を取得しただけです。そして、DOM Parse を使用して最も人気のあるセクションだけにフィルターをかけることはできませんでした。このコードで発生しているエラーは、編集されていないドキュメントの関数find()エラーです>simple_html_dom.php

基本的に、bbc.co.uk/news セクションの最も人気のあるセクションを単独で取得する方法がわかりません。

4

0 に答える 0