I have a "parse" method. Now we use recursion, follow the links of the site and take only the first link from the pages. And how can I take all the links of each level of the site, in order to get a site map?
--index.php--
function parse($url){ $url = $this->readUrl($url); if( !$url or $this->cacheurl[$url] or $this->cacheurl[preg_replace('#/$#','',$url)] ) return false; $this->_allcount--; if( $this->_allcount<=0 ) return false; $this->cacheurl[$url] = true; $item = array(); $data = str_get_html(request($url)); $item['url'] = $url; $item['title'] = count($data->find('title'))?$data->find('title',0)->plaintext:''; $this->result[] = $item; if(count($data->find('a'))){ foreach($data->find('a') as $a){ $this->parse($a->href); } } $data->clear(); unset($data); } function printresult(){ foreach($this->result as $item){ echo ''.$item['title'].' - <small>'.$item['url'].'</small>'; //echo '<p style="margin:20px 0px;background:#eee; padding:20px;">'.$item['text'].'</p>'; }; exit(); }