Search code examples
phphtmlhtml-content-extraction

PHP: Data from cURL, HTML Scan


How can i scan a html page, for text within a certain div?


Solution

  • The simplest way to do this would be to use Simple HTML DOM parser

    // Create a DOM object from a URL
    $html = file_get_html('http://www.google.com/');    
    
    // Find all <div> which attribute id=foo
    $ret = $html->find('div[id=foo]');