1 | <?php
|
---|
2 |
|
---|
3 | class MeetSourceEso extends MeetSource
|
---|
4 | {
|
---|
5 | function Import(): string
|
---|
6 | {
|
---|
7 | $Output = parent::Import();
|
---|
8 | $Content = file_get_contents($this->URL);
|
---|
9 |
|
---|
10 | $BlockStart = '<h2>Seznam inzerátů';
|
---|
11 | $BlockEnd = '<nav><ul';
|
---|
12 | $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
|
---|
13 | if ($Content == '')
|
---|
14 | {
|
---|
15 | $Output .= 'Main block not isolated.</br>';
|
---|
16 | return $Output;
|
---|
17 | }
|
---|
18 |
|
---|
19 | $ItemStart = '<div class="panel panel-default">';
|
---|
20 | $ItemEnd = "</div>
|
---|
21 | </div>";
|
---|
22 | while (strpos($Content, $ItemStart) !== false)
|
---|
23 | {
|
---|
24 | $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
|
---|
25 | $MeetItem = new MeetItem();
|
---|
26 |
|
---|
27 | $MeetItem->Name = trim(GetTextBetween($Item, '<h3 class="panel-title tucne">', '/'));
|
---|
28 | $Gender = trim(GetTextBetween($Item, ' ', '</h3'));
|
---|
29 | if (strpos($Gender, 'partnerku') !== false) $MeetItem->Gender = Gender::Male;
|
---|
30 | else if (strpos($Gender, 'partnera') !== false) $MeetItem->Gender = Gender::Female;
|
---|
31 | else $MeetItem->Gender = Gender::Undefined;
|
---|
32 | $Small = GetTextBetween($Item, '<small>', '</small>');
|
---|
33 | if (strpos($Small, '/') != false)
|
---|
34 | {
|
---|
35 | $MeetItem->Location = substr(trim(substr($Small, 0, strpos($Small, '/') - 1)), 1, -1);
|
---|
36 | $Small = substr($Small, strpos($Small, '/') + 1);
|
---|
37 | }
|
---|
38 | $Time = trim($Small);
|
---|
39 | $MeetItem->Time = HumanDateToTime($Time);
|
---|
40 | $MeetItem->Message = trim(GetTextBetween($Item, '<p class="lead">', '</p>'));
|
---|
41 | $MeetItem->Age = GetAgeFromText($MeetItem->Message);
|
---|
42 | $MeetItem->Height = GetHeightFromText($MeetItem->Message);
|
---|
43 | $MeetItem->Weight = GetWeightFromText($MeetItem->Message);
|
---|
44 | $Location = GetLocationFromText($MeetItem->Message);
|
---|
45 | if ($Location != '') $MeetItem->Location = $Location;
|
---|
46 | if ($MeetItem->Location == '') $MeetItem->Location = 'Brno';
|
---|
47 | $MeetItem->Email = '';
|
---|
48 | $MeetItem->Phone = '';
|
---|
49 | $MeetItem->Link = trim(GetTextBetween($Item, '<a href="', '"'));
|
---|
50 | $MeetItem->Database = $this->Database;
|
---|
51 | $MeetItem->Source = $this->Id;
|
---|
52 | $this->MeetItems[] = $MeetItem;
|
---|
53 | }
|
---|
54 | return $Output;
|
---|
55 | }
|
---|
56 | }
|
---|