Friday, 23 January 2015

Get All Links From Sites. - PHP

Here Display all links from sites or files.. Just give the path for your files or sites.
For Example:
$path='http://www.hscripts.com/';
 Which Links are used in that Sites that links are Displayed
<?php
$path='http://www.hscripts.com/'
$html = file_get_contents($path);

$dom = new DOMDocument();
@$dom->loadHTML($html);

// grab all the on the page
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");

for ($i = 0; $i < $hrefs->length; $i ) {
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
echo $url.'<br />';
}
?>

0 comments:

Post a Comment