Get All Links From Sites. - Php

Get All Links

Snippet Code


  
Rate this page :
  [ 0 votes]

Here Display all links from sites or files.. Just give the path for your files or sitesFor 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.' '; } ?>

Tags


Ask Questions

Ask Question