A blog for technology, SEO tips, website development and open source programming.

Find All Links on a Page with PHP

1 713

This post will demostrate how you can find all links on a website using php code.

$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.’

1 Comment
  1. Helga Phillippy says

    Pretty! This was an extremely wonderful post. Thanks for supplying this information.

Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More