I am trying to use the code bellow to fetch some posts from my blog but it's a little difficult.
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);
}
My html structure is:
<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>
I want to fetch the img, the (that is y post title), that holds the short description of my post.
Thank you for one one more time guys!!!