diff options
-rw-r--r-- | bridges/JohannesBlickBridge.php | 29 | ||||
-rw-r--r-- | bridges/OMonlineBridge.php | 72 | ||||
-rw-r--r-- | bridges/UsesTechBridge.php | 30 |
3 files changed, 131 insertions, 0 deletions
diff --git a/bridges/JohannesBlickBridge.php b/bridges/JohannesBlickBridge.php new file mode 100644 index 00000000..6c00feca --- /dev/null +++ b/bridges/JohannesBlickBridge.php @@ -0,0 +1,29 @@ +<?php + +class JohannesBlickBridge extends BridgeAbstract +{ + const NAME = 'Johannes Blick'; + const URI = 'https://www.st-johannes-baptist.de/index.php/unsere-medien/johannesblick-archiv'; + const DESCRIPTION = 'RSS feed for Johannes Blick'; + const MAINTAINER = 'jummo4@yahoo.de'; + + public function collectData() + { + $html = getSimpleHTMLDOM(self::URI) + or returnServerError('Could not request: ' . self::URI); + + $html = defaultLinkTo($html, self::URI); + foreach ($html->find('td > a') as $index => $a) { + $item = []; // Create an empty item + $articlePath = $a->href; + $item['title'] = $a->innertext; + $item['uri'] = $articlePath; + $item['content'] = ''; + + $this->items[] = $item; // Add item to the list + if (count($this->items) >= 10) { + break; + } + } + } +} diff --git a/bridges/OMonlineBridge.php b/bridges/OMonlineBridge.php new file mode 100644 index 00000000..a434e44e --- /dev/null +++ b/bridges/OMonlineBridge.php @@ -0,0 +1,72 @@ +<?php + +class OMonlineBridge extends BridgeAbstract +{ + const NAME = 'OM Online Bridge'; + const URI = 'https://www.om-online.de'; + const DESCRIPTION = 'RSS feed for OM Online'; + const MAINTAINER = 'jummo4@yahoo.de'; + const PARAMETERS = [ + [ + 'ort' => [ + 'name' => 'Ortsname', + 'title' => 'Für die Anzeige von Beitragen nur aus einem Ort oder mehreren Orten + geben einen Orstnamen ein. Mehrere Ortsnamen müssen mit / getrennt eingeben werden, + z.B. Vechta/Cloppenburg. Groß- und Kleinschreibung beachten!' + ] + ] + ]; + + public function collectData() + { + if (!empty($this->getInput('ort'))) { + $url = sprintf('%s/ort/%s', self::URI, $this->getInput('ort')); + } else { + $url = sprintf('%s', self::URI); + } + + $html = getSimpleHTMLDOM($url) + or returnServerError('Could not request: ' . $url); + + $html = defaultLinkTo($html, $url); + + foreach ($html->find('div.molecule-teaser > a ') as $index => $a) { + $item = []; + + $articlePath = $a->href; + + $articlePageHtml = getSimpleHTMLDOMCached($articlePath, self::CACHE_TIMEOUT) + or returnServerError('Could not request: ' . $articlePath); + + $articlePageHtml = defaultLinkTo($articlePageHtml, self::URI); + + $contents = $articlePageHtml->find('div.molecule-article', 0); + + $item['uri'] = $articlePath; + $item['title'] = $contents->find('h1', 0)->innertext; + + $contents->find('div.col-12 col-md-10 offset-0 offset-md-1', 0); + + $item['content'] = $contents->innertext; + $item['timestamp'] = $this->extractDate2($a->plaintext); + $this->items[] = $item; + + if (count($this->items) >= 10) { + break; + } + } + } + + private function extractDate2($text) + { + $dateRegex = '/^([0-9]{4}\/[0-9]{1,2}\/[0-9]{1,2})/'; + + $text = trim($text); + + if (preg_match($dateRegex, $text, $matches)) { + return $matches[1]; + } + + return ''; + } +} diff --git a/bridges/UsesTechBridge.php b/bridges/UsesTechBridge.php new file mode 100644 index 00000000..653d83dc --- /dev/null +++ b/bridges/UsesTechBridge.php @@ -0,0 +1,30 @@ +<?php + +class UsesTechbridge extends BridgeAbstract +{ + const NAME = '/uses'; + const URI = 'https://uses.tech/'; + const DESCRIPTION = 'RSS feed for /uses'; + const MAINTAINER = 'jummo4@yahoo.de'; + const MAX_ITEM = 100; # Maximum items to loop through which works fast enough on my computer + + public function collectData() + { + $html = getSimpleHTMLDOM(self::URI) + or returnServerError('Could not request: ' . self::URI); + + foreach ($html->find('div[class=PersonInner]') as $index => $a) { + $item = []; // Create an empty item + $articlePath = $a->find('a[class=displayLink]', 0)->href; + $item['title'] = $a->find('img', 0)->getAttribute('alt'); + $item['author'] = $a->find('img', 0)->getAttribute('alt'); + $item['uri'] = $articlePath; + $item['content'] = $a->find('p', 0)->innertext; + + $this->items[] = $item; // Add item to the list + if (count($this->items) >= self::MAX_ITEM) { + break; + } + } + } +} |