Поиск<\/a><\/td>/'; $items_reg = '/(.*?)<\/td><\/tr>(.*?)<\/tr>/'; $item_name = '/(.*)<\/a>/'; $item_desc = '/
(.*)<\/div>/'; $item_price = '/(.*)<\/td>/'; if ($this->request->hasFiles() == true) { //Print the real file names and their sizes foreach ($this->request->getUploadedFiles() as $file) { //Move the file into the application $route = STORAGE_PATH . 'temp/' . $file->getName(); $file->moveTo($route); } $this->exelphp->addFile($route); $result = $this->exelphp->getRows(); } foreach($result as $row){ $proxy = \proxy::getInstance(); $page = $this->parseExistLink('price.aspx?sr=-4&pcode='.$row[1],$proxy->getProxy()); $check_items = preg_match($item_reg, $page, $check); if($check_items){ preg_match_all($items_reg, $page, $one_item); $items[] = $one_item; } else { preg_match_all($link_reg, $page, $links); $items = array(); foreach($links[1] as $link){ $page = $this->parseExistLink($link,$proxy->getProxy()); preg_match_all($items_reg, $page, $one_item); $items[] = $one_item; } } die(print_r($items)); if(!empty($items)){ $num = count($items); for($i=0; $i<$num; $i++){ /*$sub_num = count($items[$i][1]); for($x=0; $x<$sub_num; $x++){ $final_list[$i][$x] = preg_split('/\|+/', preg_replace('/<(.*?)>/', '|', $items[$i][0][$x])); }*/ preg_match_all( $item_name, $items[$i][0][0], $name); //$final_list[] = $name; } } else { die('по запросу ничего не найдено'); } // Array // ( // [0] => Array // ( // [0] => Array // ( // [0] => • Запрошенный артикул
CA......CL
Брызговики передние
------ // [1] => • Предложения по оригинальным производителям
CA......CL
Брызговики передние RR Sport
13 дн.2 262,00грн. // ) // // [1] => Array // ( // [0] => • Запрошенный артикул // [1] => • Предложения по оригинальным производителям // ) // // [2] => Array // ( // [0] => id="_0_" attr="firm_1260" bl="-10">
CA......CL
Брызговики передние
------ // [1] => id="_1_" attr="firm_59" bl="-1">
CA......CL
Брызговики передние RR Sport
13 дн.2 262,00грн. // ) // // ) // // // ) } /* if((isset($price) && !empty($price)) && (isset($h1) && !empty($h1))) { $price = preg_replace("/[^0-9]/", '', $price[1]); }*/ $this->view->setVars([ 'data' =>$final_list ]); } public function parseExistLink($url,$proxy){ $url = 'http://www.exist.ua/'.$url; $proxy = explode(':', $proxy); //$proxyauth = 'RUS143854:Z8lhjhYPUP'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); //curl_setopt($ch, CURLOPT_PROXYTYPE, 7); curl_setopt($ch, CURLOPT_PROXY, $proxy[0]); curl_setopt($ch, CURLOPT_PROXYPORT, $proxy[1]); // curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_USERAGENT , "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"); $headers = array ( 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*;q=0.8', 'Accept-Language: ru,en-us;q=0.7,en;q=0.3', 'Accept-Encoding: deflate', 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7' ); curl_setopt($ch, CURLOPT_HTTPHEADER,$headers); sleep(5); $exec = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); return preg_replace('/>\s*<', $exec); } function addAction() { $model = new \rdsServices; $model->save(); $model = \rdsServices::find(array("order" => 'id')); $model = $model->getLast(); $this->view->disableLevel(\Phalcon\Mvc\View::LEVEL_MAIN_LAYOUT); $this->view->setVars([ 'item' => $model, ]); } function deleteAction() { $id = $this->request->get('id'); $model = \rdsServices::findFirst("id = '$id'"); if($model instanceof \rdsServices) { $model->delete(); } } function updateAction() { $data = $this->request->getPost('data'); $id = $this->request->getPost('id'); $data = json_decode($data); $model = \rdsServices::findFirst(array("id = '$id'")); foreach(get_object_vars($data) as $key=>$value) { $array[$key] = $value; } $model->save($array); die(); } }