Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add n26 blog bridge #1006

Merged
merged 5 commits into from
Jan 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions bridges/N26Bridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

class N26Bridge extends BridgeAbstract
{
const MAINTAINER = 'quentinus95';
const NAME = 'N26 Blog';
const URI = 'https://n26.com';
const CACHE_TIMEOUT = 1800;
const DESCRIPTION = 'Returns recent blog posts from N26.';

public function getIcon()
{
return 'https://n26.com/favicon.ico';
}

public function collectData()
{
$html = getSimpleHTMLDOM(self::URI . '/en-fr/blog-archive')
or returnServerError('Error while downloading the website content');

foreach($html->find('div.ga') as $article) {
$item = [];

$item['uri'] = self::URI . $article->find('h2 a', 0)->href;
$item['title'] = $article->find('h2 a', 0)->plaintext;

$fullArticle = getSimpleHTMLDOM($item['uri'])
or returnServerError('Error while downloading the full article');

$dateElement = $fullArticle->find('span[class="fk fl de ch fm by"]', 0);
$item['timestamp'] = strtotime($dateElement->plaintext);
$item['content'] = $fullArticle->find('main article', 0)->innertext;

$this->items[] = $item;
}
}
}