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

Last change on this file was 68, checked in by chronos, 15 months ago
  • Fixed: Seznamka import.
File size: 2.6 KB
Line 
1<?php
2
3class MeetSourceSeznamka extends MeetSource
4{
5 function Import(): string
6 {
7 $Output = parent::Import();
8 $Content = file_get_contents($this->URL);
9 $Content = str_replace("(adsbygoogle = window.adsbygoogle || []).push({});", "", $Content);
10 $BlockStart = '<h1>Tanec ... : Seznamka</h1>';
11 $BlockEnd = 'rel=\'prev\'>Předchozí</a>';
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-xs-12\'>';
20 $ItemEnd = 'Odpovědět</a></div></div></div>';
21 while (strpos($Content, $ItemStart) !== false)
22 {
23 $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
24 if ($Item == '') break;
25 if (str_starts_with($Item, '<div class=\'box-premium\'>')) continue;
26 $MeetItem = new MeetItem();
27 //$MeetItem->Image = trim(GetTextBetween($Item, '<div', '</div>'));
28 $Gender = trim(GetTextBetween($Item, "<span class=\"ipoh", "\""));
29 if ($Gender == 'zena') $MeetItem->Gender = Gender::Female;
30 else if ($Gender == 'muz') $MeetItem->Gender = Gender::Male;
31 else $Gender = Gender::Undefined;
32 $MeetItem->Name = trim(GetTextBetween($Item, '>', '</span>'));
33 $MeetItem->Name = trim(strip_tags($MeetItem->Name));
34 $Category = trim(GetTextBetween($Item, '<span class=\'ikat\'>', '</a>'));
35 $MeetItem->Age = trim(strip_tags(GetTextBetween($Item, '<span class=\'ikat\'>', '</a>')));
36 $MeetItem->Age = trim(str_replace('let', '', $MeetItem->Age));
37 $MeetItem->Location = trim(strip_tags(GetTextBetween($Item, '<span class=\'imesto\'>', '</span>')));
38 $Time = trim(html_entity_decode(str_replace('&nbsp;', '', GetTextBetween($Item, 'TOP</a>', '</span>'))));
39 if ($Time == 'Včera') $Time = HumanDate(time() - 60*60*24);
40 else if ($Time == 'Dnes') $Time = HumanDate(time());
41 $MeetItem->Time = HumanDateToTime($Time);
42 $MeetItem->Message = trim(strip_tags(GetTextBetween($Item, '<p>', '</p>')));
43 $MeetItem->Link = GetTextBetween($Item, "<a href='", "'");
44 while (substr($MeetItem->Link, 0, 3) == '../')
45 $MeetItem->Link = substr($MeetItem->Link, 3);
46 $MeetItem->Link = 'https://www.seznamka.cz/'.$MeetItem->Link;
47 $MeetItem->Email = GetEmailFromText($MeetItem->Message);
48 $MeetItem->Phone = '';
49 $MeetItem->Height = GetHeightFromText($MeetItem->Message);
50 $MeetItem->Weight = GetWeightFromText($MeetItem->Message);
51 $MeetItem->Database = $this->Database;
52 $MeetItem->Source = $this->Id;
53 $this->MeetItems[] = $MeetItem;
54 }
55 return $Output;
56 }
57}
Note: See TracBrowser for help on using the repository browser.