Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,774 questions

51,679 answers

573 users

How to find all the links on a web page in PHP

1 Answer

0 votes
    $html = file_get_contents('http: //www.avibootz.com');
     
    $dom = new DOMDocument();
    @$dom->loadHTML($html);
     
    $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 />';
    }

/*
 
run:
 
http: //cprogramming.bootzlabs.com/get-c-compiler/
http: //collectivesolver.com/
http: //webshopy.com/
http: //www.coupondiscountblog.com/
http: //www.buyfrompictures.com/
http: //www.seek4info.com/
http: //www.occupationstools.com/
http: //www.bootzstore.com/
http: //www.allwebhostingsites.com/
http: //www.allonpage.com/
http: //www.readersbuyers.com/
http: //www.digitalproductsdeals.com/
http: //www.madalpha.com/
http: //www.bootznotes.com
http: //www.knowrex.com
 
*/

?>


answered Mar 1, 2015 by avibootz
edited Mar 1, 2015 by avibootz

Related questions

...