Last change
on this file was 938, checked in by chronos, 2 years ago |
- Fixed: Not working news import due to PHP SSL bug.
- Added: News import from zdechov.net site.
|
File size:
1.1 KB
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | class NewsSourceZdechovNET extends NewsSource
|
---|
4 | {
|
---|
5 |
|
---|
6 | function Import(): string
|
---|
7 | {
|
---|
8 | $Output = parent::Import();
|
---|
9 | $Content = file_get_contents_curl($this->URL);
|
---|
10 |
|
---|
11 | $BlockStart = '<strong>Novinky:</strong>';
|
---|
12 | $BlockEnd = '</table>';
|
---|
13 | $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
|
---|
14 | if ($Content == '')
|
---|
15 | {
|
---|
16 | $Output .= 'Main block not isolated.</br>';
|
---|
17 | return $Output;
|
---|
18 | }
|
---|
19 |
|
---|
20 | $ItemStart = '<div>';
|
---|
21 | $ItemEnd = '</div>';
|
---|
22 | while (strpos($Content, $ItemStart) !== false)
|
---|
23 | {
|
---|
24 | $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
|
---|
25 | $NewsItem = new NewsItem();
|
---|
26 |
|
---|
27 | $NewsItem->Link = 'https://www.zdechov.net';
|
---|
28 | $NewsItem->Title = GetTextBetween($Item, '<strong>', '</strong>');
|
---|
29 | $Date = GetTextBetween($Item, '<strong>(', ')</strong>');
|
---|
30 | $NewsItem->Date = HumanDateToTime($Date);
|
---|
31 | $NewsItem->Category = $this->Category;
|
---|
32 | $NewsItem->Content = html_entity_decode(GetTextBetween($Item, '<br/>', ''));
|
---|
33 | $NewsItem->Author = 'Automat';
|
---|
34 | $NewsItem->Database = $this->Database;
|
---|
35 | $this->NewsItems[] = $NewsItem;
|
---|
36 | }
|
---|
37 | return $Output;
|
---|
38 | }
|
---|
39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.