Posted By

haydin on 03/20/13


Tagged

php link page links seo finder apps


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

donnafontenot
gecube
ekarakas
codingforever99
3polars
ilker
rafpro


Find All Links on a Page


 / Published in: PHP
 

URL: giochiit

Here's the basic principal behind spiders. (ex: Giochi Flash $html = filegetcontents('http://www.example.com');

  1. $html = file_get_contents('http://www.example.com');
  2.  
  3. $dom = new DOMDocument();
  4. @$dom->loadHTML($html);
  5.  
  6. // grab all the on the page
  7. $xpath = new DOMXPath($dom);
  8. $hrefs = $xpath->evaluate("/html/body//a");
  9.  
  10. for ($i = 0; $i < $hrefs->length; $i++) {
  11. $href = $hrefs->item($i);
  12. $url = $href->getAttribute('href');
  13. echo $url.'<br />';
  14. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: sagive on April 29, 2013

i live it! made some small changes and created a great tool in my website ;) - thanks

Posted By: sagive on April 29, 2013

(spelling: i live it = i like it!)

You need to login to post a comment.