Используя phpQuery , вы можете пройти DOM и найти якоря (<a>
) с определенным атрибутом href
:
$dom = phpQuery::newDocument($htmlSource);
$anchors = $dom->find('a[href]');
$urls = array();
if($anchors) {
foreach($anchors as $anchor) {
$anchor = pq($anchor);
$urls[] = $anchor->attr('href');
}
}