0

以下のコードを使用してブログからいくつかの投稿を取得しようとしていますが、少し難しいです。

include('simple_html_dom.php');
$html->clear();
getArticles('http://www.example.com');

function getArticles($page) {
    global $articles, $descriptions;

    $html = new simple_html_dom();
    $html->load_file($page);

    $items = $html->find('li');  

    foreach($items as $post) {
        # remember comments count as nodes
        $articles[] = array($post->children(1)->innertext);
    }

私のhtml構造は次のとおりです。

<li class="post-1840 post type-post status-publish format-standard hentry category-perierga">

<a href="http://www.example.com/?p=1840" title="my post title">
<img width="200" height="179" src="images/iko-200x179.jpg" class="attachment-archive wp-post-image" alt="iko-200x179.jpg" title=""></a>

<h2 class="leading"><a href="http://www.example.com/?p=1840">My Post Title!</a></h2>

<p class="widgetmeta sserif">
6 hours ago  | 
<a href="http://www.example.com/?cat=2" title="View all posts in Weird" rel="category">Weird</a> | 
<a href="http://www.example.com/?author=1" title="Posts by adminadmin" rel="author">admin</a> | 
<span>Comments Off</span>                      
</p>
<p class="teaser">my shord post description...</p>
<a class="mainbutton fr" href="http://www.example.com/?p=1840">Read More »</a>

</li>

投稿の簡単な説明を保持する img (つまり、y 投稿のタイトル) を取得したいと考えています。

もう一度ありがとうみんな!

4

1 に答える 1