我试图使用Parser从url中提取几个链接,其中只有包含"HOROSKOPI_CATEGORY“的链接,如下所示:
<?php
include 'simple_html_dom.php';
$html = file_get_html('http://www.ikub.al/Horoskopi/Default.aspx');
foreach($html->find('a') as $element)
echo $element->href . '<br>';
?>但这是提取所有url链接。
发布于 2013-12-16 20:57:23
您需要过滤href属性,例如:
<?php
include 'simple_html_dom.php';
$html = file_get_html('http://www.ikub.al/Horoskopi/Default.aspx');
foreach($html->find('a') as $element) {
if(strpos($element->href, "Horoskopi"))
echo "http://www.ikub.al/Horoskopi/".$element->href . '<br>';
}
?>https://stackoverflow.com/questions/20620733
复制相似问题