How To: Find all links on a page with PHP – IOGOOS Solution- A leading Digital Marketing Agency

While working on a project, I needed to find all links on a given page. This code will list all links specified in an anchor tag on a given page URL. $html = file_get_contents( ‘//website.com/page-in-question’ ); $dom = new DOMDocument(); @$dom->loadHTML( $html ); $xpath = new DOMXPath( $dom ); $hrefs = $xpath->evaluate( “/html/body//a” ); for( $i … Continue reading “How To: Find all links on a page with PHP”

Be the first to comment

Leave a Reply

Your email address will not be published.


*