Friday, 6 October 2017

How to get all links from a site

Having a complete list of your site is incredibly important in the current search landscape. You need not use a tool to get all the links of your site. Use the following PHP code to get all the links

<?php
$html = file_get_contents('http://www.kayalspot.blogspot.in');
$dom = new DOMDocument();
@$dom->loadHTML($html);
// grab all the links 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 />';
}

About the Author

Unknown

Author & Editor

Hi Friends, I am Kayalvizhi doing Computer science engineering in Madurai. My hobbies are browsing, reading books and playing puzzles. I love programming. Read more

No comments:

Post a Comment

 
KayalSpot © 2015 - Designed by Templateism.com