mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[Nordbayern] fix: problem with absolute and relative link (#2637)
* [Nordbayern] fix: problem with absolute and relative link Fixes: cURL error: Could not resolve host: www.nordbayern.dehttps
This commit is contained in:
parent
7379e2b3d5
commit
5a7d305e07
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
ini_set('max_execution_time', '300');
|
|
||||||
class NordbayernBridge extends BridgeAbstract {
|
class NordbayernBridge extends BridgeAbstract {
|
||||||
|
|
||||||
const MAINTAINER = 'schabi.org';
|
const MAINTAINER = 'schabi.org';
|
||||||
@ -64,11 +64,16 @@ class NordbayernBridge extends BridgeAbstract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function getValidImages($pictures) {
|
private function getValidImages($pictures) {
|
||||||
|
|
||||||
|
if(empty($pictures)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
$images = array();
|
$images = array();
|
||||||
if(!empty($pictures)) {
|
for ($i = 0; $i < count($pictures); $i++) {
|
||||||
for($i = 0; $i < count($pictures); $i++) {
|
$img = $pictures[$i]->find('img', 0);
|
||||||
$imgUrl = $pictures[$i]->find('img', 0)->src;
|
if ($img) {
|
||||||
if(strcmp($imgUrl, 'https://www.nordbayern.de/img/nb/logo-vnp.png') !== 0) {
|
$imgUrl = $img->src;
|
||||||
|
if (strcmp($imgUrl, 'https://www.nordbayern.de/img/nb/logo-vnp.png') !== 0) {
|
||||||
array_push($images, $imgUrl);
|
array_push($images, $imgUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,8 +87,17 @@ class NordbayernBridge extends BridgeAbstract {
|
|||||||
defaultLinkTo($article, self::URI);
|
defaultLinkTo($article, self::URI);
|
||||||
|
|
||||||
$item['uri'] = $link;
|
$item['uri'] = $link;
|
||||||
$item['author'] = $article->find('[class=article__author extrabold]', 0)->plaintext;
|
|
||||||
$item['timestamp'] = strtotime(str_replace('Uhr', '', $article->find('[class=article__release]', 0)->plaintext));
|
$author = $article->find('[class=article__author extrabold]', 0);
|
||||||
|
if ($author) {
|
||||||
|
$item['author'] = $author->plaintext;
|
||||||
|
}
|
||||||
|
|
||||||
|
$createdAt = $article->find('[class=article__release]', 0);
|
||||||
|
if ($createdAt) {
|
||||||
|
$item['timestamp'] = strtotime(str_replace('Uhr', '', $createdAt->plaintext));
|
||||||
|
}
|
||||||
|
|
||||||
if ($article->find('h2', 0) == null) {
|
if ($article->find('h2', 0) == null) {
|
||||||
$item['title'] = $article->find('h3', 0)->innertext;
|
$item['title'] = $article->find('h3', 0)->innertext;
|
||||||
} else {
|
} else {
|
||||||
@ -135,17 +149,19 @@ class NordbayernBridge extends BridgeAbstract {
|
|||||||
private function handleNewsblock($listSite) {
|
private function handleNewsblock($listSite) {
|
||||||
$main = $listSite->find('main', 0);
|
$main = $listSite->find('main', 0);
|
||||||
foreach($main->find('article') as $article) {
|
foreach($main->find('article') as $article) {
|
||||||
self::handleArticle(self::URI . $article->find('a', 0)->href);
|
$url = $article->find('a', 0)->href;
|
||||||
|
$url = urljoin(self::URI, $url);
|
||||||
|
self::handleArticle($url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
$item = array();
|
|
||||||
$region = $this->getInput('region');
|
$region = $this->getInput('region');
|
||||||
if($region === 'rothenburg-o-d-t') {
|
if($region === 'rothenburg-o-d-t') {
|
||||||
$region = 'rothenburg-ob-der-tauber';
|
$region = 'rothenburg-ob-der-tauber';
|
||||||
}
|
}
|
||||||
$listSite = getSimpleHTMLDOM(self::URI . '/region/' . $region);
|
$url = self::URI . '/region/' . $region;
|
||||||
|
$listSite = getSimpleHTMLDOM($url);
|
||||||
|
|
||||||
self::handleNewsblock($listSite);
|
self::handleNewsblock($listSite);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user