aboutsummaryrefslogtreecommitdiff
path: root/bridges/WYMTNewsBridge.php
blob: c19d6e25c72b5009a0f2743652bd5bb269f7598a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php

class WYMTNewsBridge extends BridgeAbstract
{
    const NAME = 'WYMT Mountain News';
    const URI = 'https://www.wymt.com/news/';
    const DESCRIPTION = 'Returns the recent articles published on WYMT Mountain News (Hazard KY)';
    const MAINTAINER = 'mattconnell';

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

        $articles = $html->find('.card-body');

        foreach ($articles as $article) {
            $item = [];
            $url = $article->find('.headline a', 0);
            $item['uri'] = $url->href;
            $item['title'] = trim($url->plaintext);
            $item['author'] = $article->find('.author', 0)->plaintext;
            $item['content'] = $article->find('.deck', 0)->plaintext;
            $this->items[] = $item;
        }
    }
}