aboutsummaryrefslogtreecommitdiff
path: root/bridges/EngadgetBridge.php
blob: b9861b405132720d720d683b9c8364e7ed35ff11 (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
28
29
30
31
32
33
34
35
<?php

class EngadgetBridge extends FeedExpander
{
    const MAINTAINER = 'IceWreck';
    const NAME = 'Engadget Bridge';
    const URI = 'https://www.engadget.com/';
    const CACHE_TIMEOUT = 3600;
    const DESCRIPTION = 'Article content for Engadget.';

    public function collectData()
    {
        $url = 'https://www.engadget.com/rss.xml';
        $max = 10;
        $this->collectExpandableDatas($url, $max);
    }

    protected function parseItem(array $item)
    {
        $itemUrl = trim($item['uri']);
        if (!$itemUrl) {
            return $item;
        }
        // todo: remove querystring tracking
        $dom = getSimpleHTMLDOM($itemUrl);
        // figure contain's the main article image
        $article = $dom->find('figure', 0);
        // .article-text has the actual article
        foreach ($dom->find('.article-text') as $element) {
            $article = $article . $element;
        }
        $item['content'] = $article ?? '';
        return $item;
    }
}