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

Last change on this file was 63, checked in by chronos, 3 years ago
  • Modified: Used explicit types where possible for better error reporting.
  • Modified: Updated Common packaged to newer version.
  • Modified: Simplified pages title.
  • Added: Simple keyword based spam filter for meet items.
File size: 1.8 KB
Line 
1<?php
2
3class MeetSourceElla extends MeetSource
4{
5 function Import(): string
6 {
7 $Output = parent::Import();
8 $this->AddCompareTime = false;
9 $this->AddCompareRemoteId = true;
10 $Content = file_get_contents($this->URL);
11
12 $BlockStart = 'Aktuální pomáháme najít tyto taneční protějšky:';
13 $BlockEnd = '<div class="container seznamka">';
14 $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
15 if ($Content == '')
16 {
17 $Output .= 'Main block not isolated.</br>';
18 return $Output;
19 }
20
21 $ItemStart = '<div class="row">';
22 $ItemEnd = "</div>\n </div>";
23 while (strpos($Content, $ItemStart) !== false)
24 {
25 $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
26 $MeetItem = new MeetItem();
27
28 $Name = trim(GetTextBetween($Item, '<div class="col-lg-2 col-md-2 col-sm-6 col-xs-6 text-center">', '</div>'));
29 $MeetItem->Name = trim(substr($Name, 0, strpos($Name, '(')));
30 $MeetItem->Age = trim(GetTextBetween($Name, '(', 'let)'));
31 $MeetItem->Height = trim(GetTextBetween($Item, '<div class="col-lg-2 col-md-2 col-sm-6 col-xs-6 text-center">', '</div>'));
32 $MeetItem->Height = substr($MeetItem->Height, 0, strpos($MeetItem->Height, 'cm'));
33 $MeetItem->Message = trim(GetTextBetween($Item, '<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">', '</div>'));
34 $MeetItem->Weight = GetWeightFromText($MeetItem->Message);
35 $MeetItem->RemoteId = trim(GetTextBetween($Item, '<a href="odpovedet-na-inzerat/', '?'));
36 $MeetItem->Location = 'České Budějovice';
37 $MeetItem->Time = time();
38 $MeetItem->Gender = GetGenderFromName($MeetItem->Name);
39
40 $MeetItem->Database = $this->Database;
41 $MeetItem->Source = $this->Id;
42 $this->MeetItems[] = $MeetItem;
43 }
44 return $Output;
45 }
46}
47
Note: See TracBrowser for help on using the repository browser.