source: trunk/Modules/Meet/Import/AstraPraha.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.6 KB
Line 
1<?php
2
3class MeetSourceAstraPraha extends MeetSource
4{
5 function Import(): string
6 {
7 $Output = parent::Import();
8 $Content = file_get_contents($this->URL);
9
10 $BlockStart = '<h2>Tanečního partnera hledají:</h2>';
11 $BlockEnd = '<hr />';
12 $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
13 if ($Content == '')
14 {
15 $Output .= 'Main block not isolated.</br>';
16 return $Output;
17 }
18
19 $ItemStart = '<p class=\'dating-date\'>';
20 $ItemEnd = '<hr class=\'dating-spacer\' />';
21 while (strpos($Content, $ItemStart) !== false)
22 {
23 $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
24 $MeetItem = new MeetItem();
25 $Time = trim(GetTextBetween($Item, 'Vloženo:', '</p>'));
26 $MeetItem->Time = HumanDateToTime($Time);
27
28 $Gender = trim(GetTextBetween($Item, '<h3 class=\'dating-heading\'>', '</h3>'));
29 if ($Gender == 'Hledám partnerku') $MeetItem->Gender = Gender::Male;
30 else $MeetItem->Gender = Gender::Female;
31 $MeetItem->Message = trim(strip_tags(GetTextBetween($Item, '<p class=\'last-element\'>', '</p>')));
32 $MeetItem->Email = trim(GetTextBetween($Item, 'class="nowrap text-link">', '</a>'));
33 $MeetItem->Name = '';
34 $MeetItem->Age = GetAgeFromText($MeetItem->Message);
35 $MeetItem->Height = GetHeightFromText($MeetItem->Message);
36 $MeetItem->Weight = GetWeightFromText($MeetItem->Message);
37 $MeetItem->Phone = '';
38 $MeetItem->Location = 'Praha';
39 $MeetItem->Database = $this->Database;
40 $MeetItem->Source = $this->Id;
41 $this->MeetItems[] = $MeetItem;
42 }
43 return $Output;
44 }
45}
46
Note: See TracBrowser for help on using the repository browser.