function recursionSearch($doc) { global $arLink; //$arLink = array(); $name_elements = $doc->find('.ico-pagination-next'); if ($name_elements) { $link_next = pq($name_elements)->attr('href'); if ($link_next) { //echo $link_next; sleep(1); array_push($arLink, $link_next . "\r\n"); //$arLink[$count] = $link_next; //file_put_contents('catalog1.txt', $arLink); //echo $arLink[$count]; //$count++; $html = file_get_contents('http://www.mvideo.ru' . $link_next); $doc = phpQuery::newDocument($html); //$arLink = $link_next; /*foreach ($doc->find('.product-tile-title a') as $key_child => $element_items) { $pq = pq($element_items); $arItem['text_items'] = $pq->html(); $arItem['link_items'] = $pq->attr('href'); }*/ recursionSearch($doc); } } //$hz = $arLink; /*echo"<pre>"; var_dump($arLink); echo"</pre>";*/ return $arLink; }
$arLinks['item']['link_catalog'][$key_index] = $pq->attr('href') != "#" || in_array($pq->attr('href'), $arExclusion) ? $pq->attr('href') . "\r\n" : ""; } } foreach ($arExclusion as $keys => $element) { $key = array_search($element, $arLinks['item']['link_catalog']); if ($key !== false) { unset($arLinks['item']['link_catalog'][$key]); } } $arUnique = array_unique($arLinks['item']['link_catalog']); file_put_contents('categories.txt', $arUnique); foreach ($arUnique as $key_catalog => $link_child) { if (!in_array(rtrim($link_child), $arExclusion)) { sleep(10); if ($html = file_get_contents('http://www.mvideo.ru' . rtrim($link_child))) { if ($html) { $document = phpQuery::newDocument($html); $arPropsLinks = recursionSearch($document); file_put_contents('categories_page.txt', $arLink, FILE_APPEND); $arLink = array(); } } } else { break; } } sleep(10); echo 'item'; ob_flush(); flush(); require_once 'item.php';