1 | <?php
|
---|
2 |
|
---|
3 | class MeetSourceCsts extends MeetSource
|
---|
4 | {
|
---|
5 | function Import(): string
|
---|
6 | {
|
---|
7 | $Output = parent::Import();
|
---|
8 | $Content = file_get_contents($this->URL);
|
---|
9 |
|
---|
10 | $BlockStart = '<div class="inzeraty">';
|
---|
11 | $BlockEnd = '</div></div>';
|
---|
12 | $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
|
---|
13 | if ($Content == '')
|
---|
14 | {
|
---|
15 | $Output .= 'Main block not isolated.</br>';
|
---|
16 | return $Output;
|
---|
17 | }
|
---|
18 |
|
---|
19 | $ItemStart = '<table>';
|
---|
20 | $ItemEnd = "</table>";
|
---|
21 | while (strpos($Content, $ItemStart) !== false)
|
---|
22 | {
|
---|
23 | $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
|
---|
24 | $MeetItem = new MeetItem();
|
---|
25 |
|
---|
26 | $Gender = trim(html_entity_decode(GetTextBetween($Item, 'class="kategorie">', '<div')));
|
---|
27 | if ($Gender == 'Hledám partnera') $MeetItem->Gender = Gender::Female;
|
---|
28 | else if ($Gender == 'Hledám partnerku') $MeetItem->Gender = Gender::Male;
|
---|
29 | else $MeetItem->Gender = Gender::Undefined;
|
---|
30 | $MeetItem->Name = trim(html_entity_decode(GetTextBetween($Item, 'Vložil/a', ',')));
|
---|
31 | $Time = trim(GetTextBetween($Item, ' ', '</th>'));
|
---|
32 | $MeetItem->Time = HumanDateTimeToTime($Time);
|
---|
33 | $MeetItem->Height = trim(GetTextBetween($Item, "výška:", 'cm'));
|
---|
34 | $MeetItem->Message = trim(html_entity_decode(strip_tags(GetTextBetween($Item, '<td colspan="3">', '</td>'))));
|
---|
35 | // Replace unicode non-breakable space by normal space
|
---|
36 | $MeetItem->Message = str_replace("\xc2\xa0", "\x20", $MeetItem->Message);
|
---|
37 | $MeetItem->Age = GetAgeFromText($MeetItem->Message);
|
---|
38 | $MeetItem->Height = GetHeightFromText($MeetItem->Message);
|
---|
39 | $MeetItem->Weight = GetWeightFromText($MeetItem->Message);
|
---|
40 | $MeetItem->Location = GetLocationFromText($MeetItem->Message);
|
---|
41 | $MeetItem->Email = trim(GetTextBetween($Item, '<strong>', '</strong>'));
|
---|
42 | $MeetItem->Phone = trim(html_entity_decode(strip_tags(GetTextBetween($Item, 'Telefon:', '</td>'))));
|
---|
43 | if ($MeetItem->Phone == 'neuveden') $MeetItem->Phone = '';
|
---|
44 | $MeetItem->Link = '';
|
---|
45 | $MeetItem->Database = $this->Database;
|
---|
46 | $MeetItem->Source = $this->Id;
|
---|
47 | $this->MeetItems[] = $MeetItem;
|
---|
48 | }
|
---|
49 | return $Output;
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|