Search code examples
phphtmlphpcrawl

single page web crawl in PHP


I am new to PHP. Can someone help me figure out how to crawl single html page and print all the words in the source code of that page?


Solution

  • $words = explode(" ", strip_tags(file_get_contents("www.example.com"));
    function trim_and_print(&$value) 
    { 
        trim($value);
        if(strlen($value > 3) 
            echo $value;
    }
    
    array_walk($words, 'trim_and_print');
    

    this should print words with length > 3. Thanks to moteutsch for file_get_contents