Parsing HTML: Call to a member function > children() on a non-object

Posted by sm56d on Stack Overflow See other posts from Stack Overflow or by sm56d
Published on 2010-06-02T17:37:17Z Indexed on 2010/06/02 17:43 UTC
Read the original article Hit count: 221

Filed under:
|
|

Hello all,

I was just helped with this question but I can't get it to move to the next block of HTML.

$html = file_get_html('http://music.banadir24.com/singer/aasha_abdoo/247.html');

$urls = $html->find('table[width=100%] table tr');

foreach($urls as $url){

     $song_name = $url->children(2)->plaintext;

     $url = $url->children(6)->children(0)->href;   

}

It returns the list of the names of the first album (Deesco) but it does not continue to the next album (The Best Of Aasha)? It just gives me this error:

Notice: Trying to get property of non-object in C:\wamp\www\test3.php on line 26

Fatal error: Call to a member function children() on a non-object in C:\wamp\www\test3.php on line 28

Why is this and how can I get it to continue to the next table element?

I appreciate any help on this!

Please note: This is legal as the songs are not bound by copyright and they are available to download freely, its just I need to download a lot of them and I can't sit there clicking a button all day. Having said that, its taken me an hour to get this far.

© Stack Overflow or respective owner

Related posts about php

Related posts about html