나는 주어진 웹 URL에서 모든 하이퍼 링크 (URL)를 추출하는 다음 코드를 가지고 있습니다.simplehtmldom URL 추출 및 패턴 일치
<?php include "simple_html_dom.php";
$html=new simple_html_dom();
$html->load_file('http://www.indiastudychannel.com/colleges');
$links=$html->find('a');
foreach($links as $l)
{
$path='http://www.indiastudychannel.com/colleges'.$l->href;
//doScrape($path);
echo $path."<br>";
}
?>
위의 코드는 모든 하이퍼 링크를 추출하지만 다음 패턴이있는 링크 만 추출하려고합니다.
http://www.indiastudychannel.com/colleges/54499-Godavari-College-Nursing.aspx http://www.indiastudychannel.com/colleges/54489-Rvs-College-Arts-And-Science.aspx http://www.indiastudychannel.com/colleges/54488-Sankara-Institute-Management.aspx
나는이가 정규 표현식을 사용하지만 어떻게 정확하게 할 수 있다는 사실을 알고 나는 모릅니다. 제가 이해하기 쉽게 예를 들어주세요.