From 37e3d6f2f6a87cfe79acc8dffeeda5bce530e95a Mon Sep 17 00:00:00 2001 From: quickwick <2566133+quickwick@users.noreply.github.com> Date: Fri, 25 Mar 2022 13:35:06 -0700 Subject: [PATCH] [CBCEditorsBlogBridge] New bridge (#2487) --- bridges/CBCEditorsBlogBridge.php | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 bridges/CBCEditorsBlogBridge.php diff --git a/bridges/CBCEditorsBlogBridge.php b/bridges/CBCEditorsBlogBridge.php new file mode 100644 index 00000000..c7feb344 --- /dev/null +++ b/bridges/CBCEditorsBlogBridge.php @@ -0,0 +1,36 @@ +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'] = '
' . $summary; + $item['author'] = 'Editor\'s Blog'; + + if(isset($item['title'])) { + $this->items[] = $item; + } + } + } +}