- Timestamp:
- Nov 15, 2023, 12:40:49 AM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Meet/Import/TanecniSkola.php
r63 r69 28 28 $Content = file_get_contents($this->URL); 29 29 30 $BlockStart = ' <div><!--[if IE]><input type=IEbug disabled style="display:none"><![endif]--></div>';31 $BlockEnd = '</ article>';30 $BlockStart = 'data-content="inzeraty">'; 31 $BlockEnd = '</section>'; 32 32 $Content = GetTextBetween($Content, $BlockStart, $BlockEnd); 33 33 if ($Content == '') … … 37 37 } 38 38 39 $ItemStart = '<div >';40 $ItemEnd = ' </div>';39 $ItemStart = '<div class="item item-dating">'; 40 $ItemEnd = 'Odpovědět na inzerát</a></p>'; 41 41 $PreviousTime = null; 42 42 while (strpos($Content, $ItemStart) !== false) … … 46 46 { 47 47 $MeetItem = new MeetItem(); 48 $MeetItem->Time = HumanDateToTime(trim(GetTextBetween($Item, '<h3>', '</h3>'))); 48 $Time = trim(GetTextBetween($Item, '<p class="date">', '</p>')); 49 if ($Time == 'Včera') $Time = HumanDate(time() - 60*60*24); 50 else if ($Time == 'Dnes') $Time = HumanDate(time()); 51 else { 52 $Time = str_replace('ledna', '1.', $Time); 53 $Time = str_replace('února', '2.', $Time); 54 $Time = str_replace('března', '3.', $Time); 55 $Time = str_replace('dubna', '4.', $Time); 56 $Time = str_replace('května', '5.', $Time); 57 $Time = str_replace('června', '6.', $Time); 58 $Time = str_replace('července', '7.', $Time); 59 $Time = str_replace('srpna', '8.', $Time); 60 $Time = str_replace('září', '9.', $Time); 61 $Time = str_replace('října', '10.', $Time); 62 $Time = str_replace('listopadu', '11.', $Time); 63 $Time = str_replace('prosince', '1.', $Time); 64 } 65 $MeetItem->Time = HumanDateToTime($Time); 49 66 if ($MeetItem->Time != null) 50 67 { … … 52 69 } else $MeetItem->Time = $PreviousTime; 53 70 54 $Part = GetTextBetween($Item, '</strong>', '<strong>'); 55 $Part = explode(',', $Part); 56 if (count($Part) > 0) $MeetItem->Name = trim($Part[0]); 57 if (count($Part) > 1) $MeetItem->Height = trim($Part[1]); 58 if (strpos($MeetItem->Height, '(') !== false) 71 $Part = GetTextBetween($Item, '<h2>', '</h2>'); 72 if (strpos($Part, '(') !== false) 59 73 { 60 $MeetItem->Age = substr($MeetItem->Height, strpos($MeetItem->Height, '(') + 1); 74 $MeetItem->Name = substr($Part, 0, strpos($Part, '(')); 75 $MeetItem->Age = substr($Part, strpos($Part, '(') + 1); 61 76 $MeetItem->Age = substr($MeetItem->Age, 0, strpos($MeetItem->Age, ')')); 62 77 $MeetItem->Age = trim(str_replace('let', '', $MeetItem->Age)); 63 $MeetItem->Height = trim(substr($MeetItem->Height, 0, strpos($MeetItem->Height, '('))); 64 } else $MeetItem->Age = ''; 78 } else 79 { 80 $MeetItem->Name = $Part; 81 $MeetItem->Age = ''; 82 } 83 84 $Gender = trim(GetTextBetween($Item, '</em>', '</p></div>')); 85 if ($Gender == 'Hledám partnera') $MeetItem->Gender = Gender::Female; 86 else if ($Gender == 'Hledám partnerku') $MeetItem->Gender = Gender::Male; 87 else $MeetItem->Gender = Gender::Undefined; 88 89 $MeetItem->Height = trim(GetTextBetween($Item, '<div class="item py-5 px-10"><p><em class="fa fa-ruler"></em>', '</p></div>')); 65 90 while (strpos($MeetItem->Height, ' ') !== false) 66 91 { … … 69 94 if (array_key_exists($MeetItem->Height, $HeightRange)) 70 95 $MeetItem->Height = $HeightRange[$MeetItem->Height]; 71 $MeetItem->Email = trim(GetTextBetween($Item, '">', '</a>')); 72 $MeetItem->Phone = trim(GetTextBetween($Item, 'tel.:', '<br />')); 73 $Gender = trim(GetTextBetween($Item, '</strong>', '<strong>')); 74 if ($Gender == 'partnera,') $MeetItem->Gender = Gender::Female; 75 else if ($Gender == 'partnerku,') $MeetItem->Gender = Gender::Male; 76 else $MeetItem->Gender = Gender::Undefined; 77 $MeetItem->Message = trim(GetTextBetween($Item, '<p class="message">', '</p>')); 96 97 $MeetItem->Message = trim(GetTextBetween($Item, '<p>', '</p>')); 98 99 $MeetItem->Email = GetEmailFromText($MeetItem->Message); 78 100 $MeetItem->Weight = GetWeightFromText($MeetItem->Message); 101 79 102 // Update age only if it is not set already 80 103 if ($MeetItem->Age == '') … … 83 106 if ($MessageAge != '') $MeetItem->Age = $MessageAge; 84 107 } 108 85 109 // Update height from message text even if height is already set 86 110 // because it can be more precise 87 111 $MessageHeight = GetHeightFromText($MeetItem->Message); 88 112 if ($MessageHeight != '') $MeetItem->Height = $MessageHeight; 113 89 114 $MeetItem->Location = 'Praha'; 90 115 $MeetItem->Database = $this->Database; 91 116 $MeetItem->Source = $this->Id; 117 //print_r($MeetItem); 92 118 $this->MeetItems[] = $MeetItem; 93 119 }
Note:
See TracChangeset
for help on using the changeset viewer.