Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $result['id'] = $id;
- $result['url'] = $url;
- $html = file_get_html($url);
- $title = $html->find('h1', 0)->plaintext;
- $title = explode(' (код',$title);
- $result['title'] = $title[0];
- $photos = $html->find('#thumbs a');
- foreach($photos as $photo){
- $result['photos'][] = $photo->src;
- }
- $map = $html->find('#map', 0)->innertext;
- $regexp = "(\[\d*\.?\d*,\s*\d*\.?\d*\])";
- if(preg_match_all("/$regexp/siU", $map, $matches, PREG_SET_ORDER)) {
- $geo = preg_replace("/[^0-9,.]/","",$matches[0][0]);
- $geo = explode(',',$geo);
- $result['geo']['lat'] = $geo[0];
- $result['geo']['lon'] = $geo[1];
- }
- $labels = $html->find('table.object-view td.label');
- $values = $html->find('table.object-view td.value');
- foreach($labels as $k=>$v){
- if($v->plaintext == 'Дата создания / изменения'){
- $date = explode(' / ',$values[$k]->plaintext);
- $result['created'] = strtotime($date[0]);
- $result['updated'] = strtotime($date[1]);
- }
- if($v->plaintext == 'Телефоны'){
- $phones = $values[$k]->find('strong', 0)->plaintext;
- $phones = explode(', ', $phones);
- $result['phones'] = $phones;
- }
- if($v->plaintext == 'Область'){
- $result['region'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Населенный пункт'){
- $result['city'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Адрес'){
- $result['address'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Район города'){
- $area = explode(':', $values[$k]->plaintext);
- $result['area'] = $area;
- }
- if($v->plaintext == 'Метро'){
- $metro = rtrim($values[$k]->plaintext, ")");
- $metro = explode('( ', $metro);
- $metro = array_reverse($metro);
- $result['metro'] = $metro;
- }
- if($v->plaintext == 'Комнат всего/разд.'){
- $phones = $values[$k]->find('strong', 0)->plaintext;
- $rooms = explode(' / ', $rooms);
- $result['rooms_total'] = $rooms[0];
- $result['rooms_living'] = $rooms[1];
- }
- if($v->plaintext == 'Этаж / этажность'){
- $floor = explode(' / ', $values[$k]->plaintext);
- $result['floor'] = $floor[0];
- $result['floor_total'] = $floor[1];
- }
- if($v->plaintext == 'Тип дома'){
- $result['construction'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Плошадь общая/жилая/кухня'){
- $surface = str_replace(' м²', '', $values[$k]->plaintext);
- $surface = explode(' / ', $surface);
- $result['surface_total'] = $surface[0];
- $result['surface_living'] = $surface[1];
- $result['surface_kitchen'] = $surface[2];
- }
- if($v->plaintext == 'Телефон'){
- $result['inner_phone'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Полы'){
- $result['floors'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Ремонт'){
- $result['repair'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Год постройки'){
- $result['year'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Сан/узел'){
- $result['toilet'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Балкон'){
- $result['balcony'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Примечания'){
- $result['comment'] = $values[$k]->find('div', 0)->plaintext;
- }
- if($v->plaintext == 'Условия продажи'){
- $result['conditions'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Собственность'){
- $result['property'] = $values[$k]->plaintext;
- }
- if($v->plaintext == 'Цена'){
- $price = str_replace(' м²', '', $values[$k]->find('strong', 0)->plaintext);
- if (strpos($price,'торг') !== false) {
- $result['negotiable'] = '1';
- } else {
- $result['negotiable'] = '0';
- }
- $price = explode(',',$price);
- $result['price_total'] = preg_replace("/[^0-9]/","",$price[0]);
- $result['price_metr'] = preg_replace("/[^0-9]/","",$price[1]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement