<?php
$url=”http://www.yourdomain.com”;
$html = file_get_contents($ur]);
//Parse it. Here we use loadHTML as a static method
//to parse the HTML and create the DOM object in one go.
@$dom = DOMDocument::loadHTML($html);
//Init the XPath object
$xpath = new DOMXpath($dom);
//Query the DOM Using DIV ID
$links = $xpath->query( ‘//a[@id = "yourtargetedDIVid "]‘ );
//Query the DOM Using Class Name
$links = $xpath->query( ‘//a[@class = "yourtargetedClassName"]‘ );
foreach ($links as $link) {
echo $link->getAttribute(‘href’);
}
?>
No comments:
Post a Comment