mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[New Bridge] Correio da Feira (regional newspaper) (#3443)
This commit is contained in:
parent
54d626d5cd
commit
98b72b2c5c
68
bridges/CorreioDaFeiraBridge.php
Normal file
68
bridges/CorreioDaFeiraBridge.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class CorreioDaFeiraBridge extends BridgeAbstract
|
||||||
|
{
|
||||||
|
const NAME = 'Correio da Feira';
|
||||||
|
const URI = 'https://www.correiodafeira.pt/';
|
||||||
|
const DESCRIPTION = 'Returns news from the Portuguese local newspaper Correio da Feira';
|
||||||
|
const MAINTAINER = 'rmscoelho';
|
||||||
|
const PARAMETERS = [
|
||||||
|
[
|
||||||
|
'feed' => [
|
||||||
|
'name' => 'News Feed',
|
||||||
|
'type' => 'list',
|
||||||
|
'title' => 'Feeds from the Portuguese sports newspaper A BOLA.PT',
|
||||||
|
'values' => [
|
||||||
|
'Cultura' => 'cultura',
|
||||||
|
'Desporto' => 'desporto',
|
||||||
|
'Economia' => 'economia',
|
||||||
|
'Entrevista' => 'entrevista',
|
||||||
|
'Freguesias' => 'freguesias',
|
||||||
|
'Justiça' => 'justica',
|
||||||
|
'Opinião' => 'opiniao',
|
||||||
|
'Política' => 'politica',
|
||||||
|
'Reportagem' => 'reportagem',
|
||||||
|
'Sociedade' => 'sociedade',
|
||||||
|
'Tecnologia' => 'tecnologia',
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getIcon()
|
||||||
|
{
|
||||||
|
return 'https://www.correiodafeira.pt/wp-content/uploads/base_reporter-200x200.jpg';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getURI()
|
||||||
|
{
|
||||||
|
switch ($this->queriedContext) {
|
||||||
|
case 'feed':
|
||||||
|
$url = self::URI . $this->getInput('feed')[0] . '.html';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$url = self::URI;
|
||||||
|
}
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collectData()
|
||||||
|
{
|
||||||
|
$url = sprintf('https://www.correiodafeira.pt/categoria/%s', $this->getInput('feed'));
|
||||||
|
$dom = getSimpleHTMLDOM($url);
|
||||||
|
$dom = $dom->find('main', 0);
|
||||||
|
if (!$dom) {
|
||||||
|
throw new \Exception(sprintf('Unable to find css selector on `%s`', $url));
|
||||||
|
}
|
||||||
|
$dom = defaultLinkTo($dom, $this->getURI());
|
||||||
|
foreach ($dom->find('div.post') as $article) {
|
||||||
|
$a = $article->find('div.blog-box', 0);
|
||||||
|
$this->items[] = [
|
||||||
|
'title' => $a->find('h2.entry-title > a', 0)->plaintext,
|
||||||
|
'uri' => $a->find('h2.entry-title > a', 0)->href,
|
||||||
|
'author' => $a->find('li.post-author > a', 0)->plaintext,
|
||||||
|
'content' => $a->find('.entry-content > p', 0)->plaintext,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user