aboutsummaryrefslogtreecommitdiff
path: root/bridges/ComboiosDePortugalBridge.php
blob: 7b2381b93dbc359738956fb9dcf1aefc151e17e1 (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
<?php

class ComboiosDePortugalBridge extends BridgeAbstract
{
    const NAME = 'CP | Avisos';
    const BASE_URI = 'https://www.cp.pt';
    const URI = self::BASE_URI . '/passageiros/pt';
    const DESCRIPTION = 'Comboios de Portugal | Avisos';
    const MAINTAINER = 'somini';

    public function collectData()
    {
        # Do not verify SSL certificate (the server doesn't send the intermediate)
        # https://github.com/RSS-Bridge/rss-bridge/issues/2397
        $html = getSimpleHTMLDOM($this->getURI() . '/consultar-horarios/avisos', [], [
            CURLOPT_SSL_VERIFYPEER => 0,
        ]);

        foreach ($html->find('.warnings-table a') as $element) {
            $item = [];

            $item['title'] = $element->innertext;
            $item['uri'] = self::BASE_URI . implode('/', array_map('urlencode', explode('/', $element->href)));

            $this->items[] = $item;
        }
    }
}