I want to find and print all mp3 links from a html web page.
<a href="http://example1.com">Test 1</a>
<a href="http://example2.com/page.html">Test 2</a>
<a href="http://example3.com/link/file2.mp3">mp3 link 2</a>
<a href="http://example3.com/link/file3.mp3">mp3 link 3</a>
I have that code of HTML now using php i want to print both mp3 links in my web page so please help me. i think DOM may help me here but i do not know how ? you may use DOM or other. Thanks you
Let clear -
$dom = new DomDocument();
$dom->loadHTML($html);
$urls = $dom->getElementsByTagName('a');
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
if(preg_match_all("/$regexp/siU", $urls, $matches, PREG_SET_ORDER))
{ foreach($urls as $match)
{// $match[2] = link address
// $match[3] = link text}
}
That will print all link but i want to print a link which have .mp3 expedition. I think now it's clear. so please help