You Are Here Home > Get All The URLs In a Web Page

Get All The URLs In a Web Page

To do this, you need to use regular expressions:

$txt = file_get_contents('http://www.codingrecipes.com/');
preg_match_all('#<a\s+href=(?:"|\')(.+?)(?:"|\')#i', $txt, $matches);
foreach ($matches[1] as $url)
    echo "$url\n<br />";
Get All The URLs In a Web Page
Filed under: PHP   Posted by: Hamid

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment