[N26] fix: broken css selectors (#2639)

This commit is contained in:
Dag 2022-04-12 23:34:52 +02:00 committed by GitHub
parent 9e2e32a19d
commit b6e8e3ea6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 20 deletions

View File

@ -8,28 +8,36 @@ class N26Bridge extends BridgeAbstract
const CACHE_TIMEOUT = 1800; const CACHE_TIMEOUT = 1800;
const DESCRIPTION = 'Returns recent blog posts from N26.'; const DESCRIPTION = 'Returns recent blog posts from N26.';
public function collectData()
{
$limit = 5;
$url = 'https://n26.com/en-eu/blog/all';
$html = getSimpleHTMLDOM($url);
$articles = $html->find('div[class="bl bm"]');
foreach($articles as $article) {
$item = array();
$itemUrl = self::URI . $article->find('a', 1)->href;
$item['uri'] = $itemUrl;
$item['title'] = $article->find('a', 1)->plaintext;
$fullArticle = getSimpleHTMLDOM($item['uri']);
$createdAt = $fullArticle->find('time', 0);
$item['timestamp'] = strtotime($createdAt->plaintext);
$this->items[] = $item;
if (count($this->items) >= $limit) {
break;
}
}
}
public function getIcon() public function getIcon()
{ {
return 'https://n26.com/favicon.ico'; return 'https://n26.com/favicon.ico';
} }
public function collectData()
{
$html = getSimpleHTMLDOM(self::URI . '/en-eu/blog-archive');
foreach($html->find('div[class="ag ah ai aj bs bt dx ea fo gx ie if ih ii ij ik s"]') as $article) {
$item = array();
$item['uri'] = self::URI . $article->find('h2 a', 0)->href;
$item['title'] = $article->find('h2 a', 0)->plaintext;
$fullArticle = getSimpleHTMLDOM($item['uri']);
$dateElement = $fullArticle->find('time', 0);
$item['timestamp'] = strtotime($dateElement->plaintext);
$item['content'] = $fullArticle->find('div[class="af ag ah ai an"]', 1)->innertext;
$this->items[] = $item;
}
}
} }