使用PHP从许多(如10,000个)URL中获取元标记

I tried retrieved meta tags of products (like 10,000) from an e-commerce site. The script works sometimes and fails rest of the time. The error I face is

Fatal error: Call to a member function find() on a non-object in ...

Please suggest better way of doing this.

Here is the code I'm using:

 $url = "http://www.amazon.com/dp/".$asin;
    $html = file_get_html( $url );
    $metatags = array();

foreach( $html->find( 'meta[name]' ) as $meta ) {
            $metatags[ 'meta' ][] = array(
            'name' => $meta->name,
            'content' => $meta->content
        );
    }

As noted by @Dagon is a better approach to use the Amazon API, this link have a good tutorial in this topic

Any way, to solve the code problem try this:

    $url = "http://www.amazon.com/dp/".$asin;
    $html = file_get_html( $url );
    $metatags = array();

    $names = array();
    try{
        $names = $html->find( 'meta[name]' );
    }
    catch(Exception $e)
    {
        error_log("Error: ".$e->getMessage());
    }

    foreach( $names as $meta ) {
            $metatags[ 'meta' ][] = array(
            'name' => $meta->name,
            'content' => $meta->content
        );
    }