Esempio n. 1
0
 public static function saveParseOlxAuto()
 {
     foreach (self::$urls as $id => $auto) {
         foreach (parent::$cities as $city) {
             $xml = file_get_contents('http://olx.ua/transport/' . $auto . '/' . $city . '/rss/');
             $movies = new \SimpleXMLElement($xml, LIBXML_NOCDATA);
             unset($xml);
             foreach ($movies->channel->item as $item) {
                 if (parent::productUnique(trim((string) $item->link))) {
                     preg_match("/Цена:\\s\\d(.*?)\\sгрн/", $item->description, $m);
                     if (isset($m[0])) {
                         preg_match_all("/\\d/", str_replace(" ", "", $m[0]), $prices);
                         foreach ($prices as $price) {
                             $model = new Items();
                             $model->product = trim((string) $item->title);
                             $model->price = implode('', $price);
                             $model->url = trim((string) $item->link);
                             $model->store = self::STORE;
                             $model->phone = parent::getPhoneNumber(trim((string) $item->link));
                             $model->subcategory_id = $id;
                             $model->options = '{"b/u":"1","city":"' . $city . '"}';
                             $model->save();
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Парсинг каталога работы Olx
  */
 public static function saveParseOlxWork()
 {
     foreach (self::$category_work as $id => $work) {
         foreach (parent::$cities as $city) {
             $xml = file_get_contents('http://olx.ua/rabota/' . $work . '/' . $city . '/rss/');
             $movies = new \SimpleXMLElement($xml, LIBXML_NOCDATA);
             unset($xml);
             foreach ($movies->channel->item as $item) {
                 if (parent::productUnique(trim((string) $item->link))) {
                     $model = new Items();
                     $model->product = trim((string) $item->title);
                     $model->price = self::getPrice(trim((string) $item->link))[0];
                     $model->url = trim((string) $item->link);
                     $model->store = self::STORE;
                     $model->phone = parent::getPhoneNumber(trim((string) $item->link));
                     $model->subcategory_id = $id;
                     $model->options = '{"city":"' . $city . '"}';
                     $model->save();
                 }
             }
         }
     }
 }
Esempio n. 3
0
 public function saveParseOlxSumki()
 {
     foreach (parent::$cities as $city) {
         $xml = file_get_contents('http://olx.ua/elektronika/foto-video/aksessuary-dlya-foto-videokamer/sumki/' . $city . '/rss/');
         $movies = new \SimpleXMLElement($xml, LIBXML_NOCDATA);
         unset($xml);
         foreach ($movies->channel->item as $item) {
             if (self::productUnique(trim((string) $item->link))) {
                 preg_match("/Цена:\\s\\d(.*?)\\sгрн/", $item->description, $m);
                 if (isset($m[0])) {
                     preg_match_all("/\\d/", str_replace(" ", "", $m[0]), $prices);
                     foreach ($prices as $price) {
                         $model = new Items();
                         $model->product = trim((string) $item->title);
                         $model->price = implode('', $price);
                         $model->url = trim((string) $item->link);
                         $model->store = 'Olx';
                         $model->phone = parent::getPhoneNumber(trim((string) $item->link));
                         $model->subcategory_id = 69;
                         $model->options = '{"type":"sumki-photo","b/u":"1","city":"' . $city . '"}';
                         $model->save();
                     }
                 }
             }
         }
     }
 }