PHPQuery - 获取包含特定 url 页面的所有链接

PHPQuery - get all links of contains specific url page

我正在尝试使用 PHPQuery 获取给定页面上包含特定 url 页面的所有链接。我正在使用 PHP 支持语法 PHPQuery.

include_once 'phpQuery.php';
$url = 'http://www.phonearena.com/phones/manufacturer/';
$doc = phpQuery::newDocumentFile($url);

$urls = $doc['a'];

foreach ($urls as $url) {
    echo pq($url)->attr('href') . '<br>';
}

上面的代码有效。但它显示了所有链接 我只想显示那些包含“/phones/manufacturer/”的内容。 我试过了,但它什么也没显示:

include_once 'phpQuery.php';
$url = 'http://www.phonearena.com/phones/manufacturer/';
$doc = phpQuery::newDocumentFile($url);

$urls = $doc['a'];

foreach ($urls as $url) {
    echo pq($url)->attr('href:contains("/phones/manufacturer/")') . '<br>';
}

使用下面的代码获取该网站的所有网址,

        $doc = new DOMDocument();
                @$doc->loadHTML(file_get_contents('http://www.phonearena.com/phones/manufacturer/'));

                $ahreftags = $doc->getElementsByTagName('a');

                    foreach ($ahreftags as $tag) {
                        echo "<br/>";
                        echo $tag->getAttribute('href');
                        echo "<br/>";
                    }


exit;

试试这个,有点italian guide, jquery documentation

include_once 'phpQuery.php';
$url = 'http://www.phonearena.com/phones/manufacturer/';
$doc = phpQuery::newDocumentFile($url);

$urls = $doc['a[href*="/phones/manufacturer/"]'];

foreach ($urls as $url) {
    echo pq($url)->attr('href') . '<br>';
}