2021-10-07 14:15:21 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2021-10-07 14:15:21 +03:00
|
|
|
class JornalDeNoticiasBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const NAME = 'Jornal de Notícias (PT)';
|
|
|
|
const URI = 'https://jn.pt';
|
|
|
|
const DESCRIPTION = 'Jornal de Notícias (JN.PT)';
|
|
|
|
const MAINTAINER = 'somini';
|
|
|
|
const PARAMETERS = [
|
|
|
|
'URL' => [
|
2022-07-01 16:10:30 +03:00
|
|
|
'url' => [
|
2021-10-07 14:15:21 +03:00
|
|
|
'name' => 'URL (relative)',
|
|
|
|
'exampleValue' => 'opiniao/catia-domingues.html',
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
|
|
|
]
|
2021-10-07 14:15:21 +03:00
|
|
|
];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2021-10-07 14:15:21 +03:00
|
|
|
public function getIcon()
|
|
|
|
{
|
|
|
|
return 'https://static.globalnoticias.pt/jn/common/images/favicons/favicon-128.png';
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2021-10-07 14:15:21 +03:00
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
switch ($this->queriedContext) {
|
|
|
|
case 'URL':
|
|
|
|
$url = self::URI . '/' . $this->getInput('url');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$url = self::URI;
|
|
|
|
}
|
|
|
|
return $url;
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2021-10-07 14:15:21 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$archives = self::getURI();
|
|
|
|
$html = getSimpleHTMLDOMCached($archives);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2021-10-07 14:15:21 +03:00
|
|
|
foreach ($html->find('article') as $element) {
|
|
|
|
$item = [];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2021-10-07 14:15:21 +03:00
|
|
|
$title = $element->find('h2 a', 0);
|
|
|
|
$link = $element->find('h2 a', 0);
|
|
|
|
$auth = $element->find('h3 a', 0);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2021-10-07 14:15:21 +03:00
|
|
|
$item['title'] = $title->plaintext;
|
|
|
|
$item['uri'] = self::URI . $link->href;
|
|
|
|
$item['author'] = $auth->plaintext;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2021-10-07 14:15:21 +03:00
|
|
|
$snippet = $element->find('h4 a', 0);
|
|
|
|
if ($snippet) {
|
|
|
|
$item['content'] = $snippet->plaintext;
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2021-10-07 14:15:21 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|