www.webdeveloper.com
Results 1 to 3 of 3

Thread: file_get_contents

  1. #1
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    Cool file_get_contents

    I'm trying to extract content within a particular div, that div is called : <div id="info">needthis content</div>

    and perhaps another div called: <div class="fap-results" id="person-results">need this content</div>


    I'm pulling all the content right now from the page, but that's not what i need... here's what i have:

    PHP Code:
    $html file_get_contents("http://anyany.yexxxo.com/thispage");

    $dom = new DOMDocument;
    $dom->loadHTML($html);

    $items $dom->getElementsByTagName('div');

    for (
    $i 0$i $items->length$i++)
            echo 
    $items->item($i)->nodeValue "<br/>"


    Thanks in advance.

  2. #2
    Join Date
    May 2003
    Posts
    598
    do preg_match() on $html
    We do precision guesswork

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,921
    Since both of those elements have IDs, why not use DOMDocument::getElementById() and save yourself some effort?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles