SimpleHTMLDom:有没有办法只解析某些代码行?

I'm new to using SimpleHTMLDom. I'm using it to parse several url's and have it working the way I want.

The only problem is it is painfully slow to load. I'm not sure, but I think it's because I'm asking to parse so many url's.

However, I do know a certain area of the source code that I want to parse.

So my question is: is there any way of telling simpleHtmlDom to only parse a given range on the page's code so it doesn't have so much to parse?

Class Standings
{
    public static function Status($url)
    {
        require_once("include.all.php");
        require_once('simple_html_dom.php');

        // Create a DOM object from a URL
        $html = file_get_html($url);

        // Find all <div> with the id attribute
        $ret = $html->find('div#cams_view_top');


        if($ret == null)
        {
            echo "<img src='images/offline.fw.png'/>";
        }
        else
        {
            echo "<img src='images/online.fw.png'/>"; 
        }
    }
}

?>   

On parsing only some elements

I don't know if there's a way to parse only a certain portion of code, based on line numbers. I don't think so, to be honest, because it would mean that the DOM is not complete, therefore it can't be parsed correctly.

You could, for instance, ask it not to parse some elements. For instance, when you see an element you know you don't want to parse. But I don't know how to do that (would be interested to know, though).

On your more global question about your script being very slow:

SimpleHtmlDom is known to have memory leaking and this is typically problematic when parsing several documents iteratively. It's a know bug caused by PHP5 memory management itself.

So, after having created each DOM object, you should free memory like this:

public static function Status($url)
{
    require_once("include.all.php");
    require_once('simple_html_dom.php');

    $html = file_get_html($url);
    $ret = $html->find('div#cams_view_top');

    // Free memory to avoid memory leakings
    $html->clear(); 
    unset($html);

    if($ret == null)
    {
        echo "<img src='images/offline.fw.png'/>";
    }
    else
    {
        echo "<img src='images/online.fw.png'/>"; 
    }
}

Source: simpleHtmlDom documentation