source: trunk/Modules/Meet/Import/Vavruska.php

Last change on this file was 65, checked in by chronos, 3 years ago
  • Added: Meet items import from La Tropcial school.
  • Modified: Use explicit types for class fields.
  • Modified: Use utf8mb4 encoding for database.
  • Fixed: Spam items checking was inverted.
File size: 1.7 KB
Line 
1<?php
2
3class MeetSourceVavruska extends MeetSource
4{
5 function Import(): string
6 {
7 $Output = parent::Import();
8 $Content = file_get_contents($this->URL);
9
10 $BlockStart = '<h2 class="wow fadeIn">Aktuální inzeráty</h2>';
11 $BlockEnd = '<div class="container-fluid box-prihlaska" id="novy-inzerat">';
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="col-sm-12">';
20 $ItemEnd = "</div>\n".
21 ' </div>';
22 while (strpos($Content, $ItemStart) !== false)
23 {
24 $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
25 $MeetItem = new MeetItem();
26
27 $Gender = GetTextBetween($Item, '<h5 class="', '"');
28 if ($Gender == 'muz') $MeetItem->Gender = Gender::Male;
29 else if ($Gender == 'zena') $MeetItem->Gender = Gender::Female;
30 else $Gender = Gender::Undefined;
31 $MeetItem->Name = GetTextBetween($Item, '>', '<');
32 $MeetItem->Email = GetTextBetween($Item, '<p>', '</p>');
33 $MeetItem->Time = HumanDateToTime(trim(GetTextBetween($Item, '<p class="pridano">Přidáno:', '</p>')));
34 $MeetItem->Message = trim(GetTextBetween($Item, '<p class="text">', '</p>'));
35 $MeetItem->Phone = '';
36 $MeetItem->Height = GetHeightFromText($MeetItem->Message);
37 $MeetItem->Weight = GetWeightFromText($MeetItem->Message);
38 $MeetItem->Age = GetAgeFromText($MeetItem->Message);
39 $MeetItem->Location = 'Praha';
40 $MeetItem->Database = $this->Database;
41 $MeetItem->Source = $this->Id;
42 if ($MeetItem->Name == 'Nový Design Inzerátů') continue;
43 $this->MeetItems[] = $MeetItem;
44 }
45 return $Output;
46 }
47}
48
Note: See TracBrowser for help on using the repository browser.