Skip to content

Commit

Permalink
[JornalDeNoticiasBridge] Add bridge (#2293)
Browse files Browse the repository at this point in the history
  • Loading branch information
somini authored Oct 7, 2021
1 parent f0ddd68 commit ba5baaf
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions bridges/JornalDeNoticiasBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
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 = array(
'URL' => array(
'url' => array(
'name' => 'URL (relative)',
'exampleValue' => 'opiniao/catia-domingues.html',
)
)
);

public function getIcon() {
return 'https://static.globalnoticias.pt/jn/common/images/favicons/favicon-128.png';
}

public function getURI() {
switch($this->queriedContext) {
case 'URL':
$url = self::URI . '/' . $this->getInput('url');
break;
default:
$url = self::URI;
}
return $url;
}

public function collectData() {
$archives = self::getURI();
$html = getSimpleHTMLDOMCached($archives);

foreach($html->find('article') as $element) {
$item = array();

$title = $element->find('h2 a', 0);
$link = $element->find('h2 a', 0);
$auth = $element->find('h3 a', 0);

$item['title'] = $title->plaintext;
$item['uri'] = self::URI . $link->href;
$item['author'] = $auth->plaintext;

$snippet = $element->find('h4 a', 0);
if ($snippet) {
$item['content'] = $snippet->plaintext;
}

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

0 comments on commit ba5baaf

Please sign in to comment.