$email, "pass" => $pass); curl_setopt($ch, CURLOPT_POSTFIELDS,$post); curl_exec($ch); spider_notes($ch); curl_close($ch); } function spider_notes($ch) { //This finds the note links and feeds them to the parser curl_setopt($ch, CURLOPT_URL,"http://m.facebook.com/notes.php"); $data = curl_exec($ch); $html = str_get_html($data); //count posts so we can travese all pages foreach($html->find('small') as $element) { if ($buffer = strstr($element->innertext,"Notes 1 - 5 of ")) { $posts = substr($buffer,15); } } $count = 0; //the while loop CURL's through the multiple pages of your notes section while ($count < $posts) { foreach($html->find('a') as $element) { if (strstr($element->href,"/note.php")) { if (strstr($element->href,"#anchor_fbid_")) { if ($element->innertext != "Read More") find_comments($ch,html_entity_decode($element->href)); //go to and parse the note } } } $count = $count + 5; curl_setopt($ch, CURLOPT_URL,sprintf("http://m.facebook.com/notes.php?p=%s",$count)); $data = curl_exec($ch); $html = str_get_html($data); } } function find_comments($ch,$url) { //This function takes the notes page tags the data we want and strips the html then parses it //curl_setopt($ch, CURLOPT_REFERER,"http://m.facebook.com/notes.php"); curl_setopt($ch, CURLOPT_URL, sprintf("http://m.facebook.com%s",$url)); $data = curl_exec($ch); $data = charset_decode_utf_8($data); $html = str_get_html($data); $title = $html->find("div.note",0)->find("a",0)->innertext; echo "Note: " . $title . "
"; foreach ($html->find("div[id*=comments_note_]") as $element) { foreach ($element->find("div") as $scrape) { if($scrape->class == "note") { if($title != $scrape->find("a",0)->plaintext) { echo "Author: " . $scrape->find("a",0)->plaintext . "
"; } } if(!$scrape->class) { echo "Comment: " . substr($scrape->plaintext,0,-6) . "
"; } } } ?>