Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
[CBCEditorsBlogBridge] New bridge (RSS-Bridge#2487)
Browse files Browse the repository at this point in the history
  • Loading branch information
quickwick authored and Kwbmm committed Jun 17, 2022
1 parent 0a9ed2c commit 628f0f4
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions bridges/CBCEditorsBlogBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
class CBCEditorsBlogBridge extends BridgeAbstract {

const MAINTAINER = 'quickwick';
const NAME = 'CBC Editors Blog';
const URI = 'https://www.cbc.ca/news/editorsblog';
const DESCRIPTION = 'Recent CBC Editor\'s Blog posts';

public function collectData(){
$html = getSimpleHTMLDOM(self::URI);

// Loop on each blog post entry
foreach($html->find('div.contentListCards', 0)->find('a[data-test=type-story]') as $element) {
$headline = ($element->find('.headline', 0))->innertext;
$timestamp = ($element->find('time', 0))->datetime;
$articleUri = 'https://www.cbc.ca' . $element->href;
$summary = ($element->find('div.description', 0))->innertext;
$thumbnailUris = ($element->find('img[loading=lazy]', 0))->srcset;
$thumbnailUri = rtrim(explode(',', $thumbnailUris)[0], ' 300w');

// Fill item
$item = array();
$item['uri'] = $articleUri;
$item['id'] = $item['uri'];
$item['timestamp'] = $timestamp;
$item['title'] = $headline;
$item['content'] = '<img src="'
. $thumbnailUri . '" /><br>' . $summary;
$item['author'] = 'Editor\'s Blog';

if(isset($item['title'])) {
$this->items[] = $item;
}
}
}
}

0 comments on commit 628f0f4

Please sign in to comment.