Changeset 4 for trunk/Meet.php
- Timestamp:
- Aug 5, 2018, 1:12:12 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Meet.php
r3 r4 148 148 $Result = GetNumberBeforeText($Text, 'let'); 149 149 if ($Result == '') $Result = GetNumberAfterText($Text, 'Je mi'); 150 if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[0]; 150 151 return $Result; 151 152 } … … 155 156 $Result = GetNumberBeforeText($Text, 'cm'); 156 157 if ($Result == '') $Result = GetNumberBeforeText($Text, 'bez podpatků'); 158 if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[1]; 157 159 return $Result; 158 160 } … … 161 163 { 162 164 $Result = GetNumberBeforeText($Text, 'kg'); 165 if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[2]; 166 return $Result; 167 } 168 169 function GetAgeHeightWeightFromText($Text) 170 { 171 $Result = array('', '', ''); 172 $Pattern = '/[0-9]+\/[0-9]+\/[0-9]+/i'; 173 if (preg_match_all($Pattern, $Text, $Matches)) 174 { 175 $Result = explode('/', $Matches[0][0]); 176 } else 177 { 178 $Pattern = '/[0-9]+\/[0-9]+/i'; 179 if (preg_match_all($Pattern, $Text, $Matches)) 180 { 181 $Result = explode('/', $Matches[0][0]); 182 $Result[] = ''; 183 } 184 } 163 185 return $Result; 164 186 } … … 282 304 if (strpos($MeetItem->Date, 'dnes v') !== false) 283 305 $MeetItem->Date = str_replace('dnes v', HumanDate(time()), $MeetItem->Date); 306 if (strpos($MeetItem->Date, 'včera v') !== false) 307 $MeetItem->Date = str_replace('včera v', HumanDate(strtotime('-1 day', time())), $MeetItem->Date); 284 308 $MeetItem->Date = HumanDateTimeToTime($MeetItem->Date); 285 309 $MeetItem->Name = trim(GetTextBetween($Item, '<div class="comment-name">', '</div>')); … … 293 317 $MeetItem->Database = $this->Database; 294 318 $MeetItem->Source = $this->Id; 319 //print_r($MeetItem); 295 320 $MeetItem->AddIfNotExist(); 296 321 } … … 338 363 function ParseHes() 339 364 { 365 $HeightRange = array( 366 '< 120 cm' => 120, 367 '120 cm - 130 cm' => 125, 368 '125 cm - 135 cm' => 130, 369 '130 cm - 140 cm' => 135, 370 '135 cm - 145 cm' => 140, 371 '140 cm - 150 cm' => 145, 372 '145 cm - 155 cm' => 150, 373 '150 cm - 160 cm' => 155, 374 '155 cm - 165 cm' => 160, 375 '160 cm - 170 cm' => 165, 376 '165 cm - 175 cm' => 170, 377 '170 cm - 180 cm' => 175, 378 '175 cm - 185 cm' => 180, 379 '180 cm - 190 cm' => 185, 380 '185 cm - 195 cm' => 190, 381 '190 cm - 200 cm' => 195, 382 '195 cm - 205 cm' => 200, 383 '200 cm <' => 205, 384 ); 385 340 386 echo('Parsing '.$this->Name.'...</br>'); 341 387 $Content = file_get_contents($this->URL); … … 358 404 if ($Item != '') 359 405 { 360 $MeetItem = new MeetItem(); 361 $MeetItem->Date = HumanDateToTime(trim(GetTextBetween($Item, '<h3>', '</h3>'))); 362 if ($MeetItem->Date != null) 363 { 364 $PreviousTime = $MeetItem->Date; 365 } else $MeetItem->Date = $PreviousTime; 366 367 $Part = GetTextBetween($Item, '</strong>', '<strong>'); 368 $Part = explode(',', $Part); 369 if (count($Part) > 0) $MeetItem->Name = trim($Part[0]); 370 if (count($Part) > 1) $MeetItem->Height = trim($Part[1]); 371 if (strpos($MeetItem->Height, '(') !== false) 372 { 373 $MeetItem->Age = substr($MeetItem->Height, strpos($MeetItem->Height, '(') + 1); 374 $MeetItem->Age = substr($MeetItem->Age, 0, strpos($MeetItem->Age, ')')); 375 $MeetItem->Age = trim(str_replace('let', '', $MeetItem->Age)); 376 $MeetItem->Height = substr($MeetItem->Height, 0, strpos($MeetItem->Height, '(')); 377 } else $MeetItem->Age = ''; 378 $MeetItem->Weight = GetWeightFromText($MeetItem->Message); 379 $MeetItem->Email = trim(GetTextBetween($Item, '">', '</a>')); 380 $MeetItem->Phone = trim(GetTextBetween($Item, 'tel.:', '<br />')); 381 $Gender = trim(GetTextBetween($Item, '</strong>', '<strong>')); 382 if ($Gender == 'partnera,') $MeetItem->Gender = Gender::Female; 383 else if ($Gender == 'partnerku,') $MeetItem->Gender = Gender::Male; 384 else $MeetItem->Gender = Gender::Undefined; 385 $MeetItem->Message = trim(GetTextBetween($Item, '<p class="message">', '</p>')); 386 $MessageAge = GetAgeFromText($MeetItem->Message); 387 if ($MessageAge != '') $MeetItem->Age = $MessageAge; 388 $MessageHeight = GetHeightFromText($MeetItem->Message); 389 if ($MessageHeight != '') $MeetItem->Height = $MessageHeight; 390 $MeetItem->Database = $this->Database; 391 $MeetItem->Source = $this->Id; 392 $MeetItem->AddIfNotExist(); 406 $MeetItem = new MeetItem(); 407 $MeetItem->Date = HumanDateToTime(trim(GetTextBetween($Item, '<h3>', '</h3>'))); 408 if ($MeetItem->Date != null) 409 { 410 $PreviousTime = $MeetItem->Date; 411 } else $MeetItem->Date = $PreviousTime; 412 413 $Part = GetTextBetween($Item, '</strong>', '<strong>'); 414 $Part = explode(',', $Part); 415 if (count($Part) > 0) $MeetItem->Name = trim($Part[0]); 416 if (count($Part) > 1) $MeetItem->Height = trim($Part[1]); 417 if (strpos($MeetItem->Height, '(') !== false) 418 { 419 $MeetItem->Age = substr($MeetItem->Height, strpos($MeetItem->Height, '(') + 1); 420 $MeetItem->Age = substr($MeetItem->Age, 0, strpos($MeetItem->Age, ')')); 421 $MeetItem->Age = trim(str_replace('let', '', $MeetItem->Age)); 422 $MeetItem->Height = trim(substr($MeetItem->Height, 0, strpos($MeetItem->Height, '('))); 423 } else $MeetItem->Age = ''; 424 while (strpos($MeetItem->Height, ' ') !== false) 425 { 426 $MeetItem->Height = str_replace(' ', ' ', $MeetItem->Height); 427 } 428 if (array_key_exists($MeetItem->Height, $HeightRange)) 429 $MeetItem->Height = $HeightRange[$MeetItem->Height]; 430 $MeetItem->Weight = GetWeightFromText($MeetItem->Message); 431 $MeetItem->Email = trim(GetTextBetween($Item, '">', '</a>')); 432 $MeetItem->Phone = trim(GetTextBetween($Item, 'tel.:', '<br />')); 433 $Gender = trim(GetTextBetween($Item, '</strong>', '<strong>')); 434 if ($Gender == 'partnera,') $MeetItem->Gender = Gender::Female; 435 else if ($Gender == 'partnerku,') $MeetItem->Gender = Gender::Male; 436 else $MeetItem->Gender = Gender::Undefined; 437 $MeetItem->Message = trim(GetTextBetween($Item, '<p class="message">', '</p>')); 438 $MessageAge = GetAgeFromText($MeetItem->Message); 439 if ($MessageAge != '') $MeetItem->Age = $MessageAge; 440 $MessageHeight = GetHeightFromText($MeetItem->Message); 441 if ($MessageHeight != '') $MeetItem->Height = $MessageHeight; 442 $MeetItem->Database = $this->Database; 443 $MeetItem->Source = $this->Id; 444 $MeetItem->AddIfNotExist(); 393 445 } 394 446 }
Note:
See TracChangeset
for help on using the changeset viewer.