예제 #1
0
파일: ikea.php 프로젝트: netaspid/ikea-ws
 public function action_showxml()
 {
     $this->response->headers('Content-Type', 'text/xml');
     $art = $this->request->param('id');
     if ($art) {
         $mGetDataSigleObject = ORM::factory('Link')->where('articul', '=', $art)->find();
         $linkToObject = $mGetDataSigleObject->link;
         $arrayData = MyExtention::DisplayInfo($linkToObject);
         $xmlObject = MyExtention::CreateXML($arrayData);
         $view = View::factory('xml');
         $view->xml = $xmlObject;
         $this->response->body($view);
     }
 }
예제 #2
0
파일: __ikea.php 프로젝트: netaspid/ikea-ws
 public function action_index()
 {
     $url = "http://www.ikea.com/ru/ru/catalog/allproducts/";
     $html = file_get_html($url);
     $linkCat = $html->find('.textContainer a');
     $i = 0;
     foreach ($linkCat as $num => $cat) {
         $urlCat = iconv("UTF-8", "windows-1251", "http://www.ikea.com" . $linkCat[$num]->href);
         $htmlCat = file_get_html($urlCat);
         $linkGood = $htmlCat->find('.productLink');
         foreach ($linkGood as $num => $good) {
             if ($i < 50) {
                 $i++;
                 $urlGood = iconv("UTF-8", "windows-1251", "http://www.ikea.com" . $linkGood[$num]->href);
                 $info = MyExtention::DisplayInfo($urlGood);
                 //echo $info."<br>";
                 //var_dump($info);
                 foreach ($info as $key => $value) {
                     //                                   if ($key == "images") {
                     //                                         foreach ($value as $image) {
                     //                                           //echo $image . "</br>";
                     //                                       }
                     //                                   }
                     if ($key == "partnumber") {
                         //                                       $partnumber = ORM::factory('Articul')
                         //                                               ->set('number', $value)
                         //                                               ->save();
                         //$arrValue[] = $value;
                         echo $value . "</br>";
                     }
                     //                                   else {
                     //                                        //echo $key . "   " . $value . "</br>";
                     //                                   }
                 }
             } else {
                 unset($info);
                 sleep(1.25);
                 $i = 0;
             }
         }
     }
     $view = View::factory('Ikea');
     $view->partnumber = $arrValue;
     $this->response->body($view);
 }