Add bridges for JohannesBlick Steinfeld, OM Online and UsesTech (#3489)

* Add bridges for JohannesBlick Steinfeld, OM Online and UsesTech

* Fixed linit alert
This commit is contained in:
Patrick 2023-07-05 16:43:59 +02:00 committed by GitHub
parent 354317d010
commit e9af41d666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 131 additions and 0 deletions

View File

@ -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;
}
}
}
}

View File

@ -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 '';
}
}

View File

@ -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;
}
}
}
}