aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Wouter Koch <wouter.koch@artsdatabanken.no> 2022-10-05 19:41:21 +0200
committerGravatar GitHub <noreply@github.com> 2022-10-05 19:41:21 +0200
commitc4c2acab982be82c6554d5a1c16603fea4cfaaed (patch)
tree3232c237ea71ad4b8f83c48053e6bd61f3c070c7
parent8b7b32d516090e3678504b3f3b609b3220d0a771 (diff)
downloadrss-bridge-c4c2acab982be82c6554d5a1c16603fea4cfaaed.tar.gz
rss-bridge-c4c2acab982be82c6554d5a1c16603fea4cfaaed.tar.zst
rss-bridge-c4c2acab982be82c6554d5a1c16603fea4cfaaed.zip
Add NOS Nieuws & Sport Bridge (#3069)
* Add NOS Nieuws & Sport Bridge * Change classname to reflect filename (NOSBridge)
-rw-r--r--bridges/NOSBridge.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/bridges/NOSBridge.php b/bridges/NOSBridge.php
new file mode 100644
index 00000000..33cad40b
--- /dev/null
+++ b/bridges/NOSBridge.php
@@ -0,0 +1,56 @@
+<?php
+
+class NOSBridge extends BridgeAbstract
+{
+ const NAME = 'NOS Nieuws & Sport Bridge';
+ const URI = 'https://www.nos.nl';
+ const DESCRIPTION = 'NOS Nieuws & Sport';
+ const MAINTAINER = 'wouterkoch';
+
+ const PARAMETERS = [
+ [
+ 'topic' => [
+ 'type' => 'list',
+ 'name' => 'Onderwerp',
+ 'title' => 'Kies onderwerp',
+ 'values' => [
+ 'Laatste nieuws' => 'nieuws',
+ 'Binnenland' => 'nieuws/binnenland',
+ 'Buitenland' => 'nieuws/buitenland',
+ 'Regionaal nieuws' => 'nieuws/regio',
+ 'Politiek' => 'nieuws/politiek',
+ 'Economie' => 'nieuws/economie',
+ 'Koningshuis' => 'nieuws/koningshuis',
+ 'Tech' => 'nieuws/tech',
+ 'Cultuur en media' => 'nieuws/cultuur-en-media',
+ 'Opmerkelijk' => 'nieuws/opmerkelijk',
+ 'Voetbal' => 'sport/voetbal',
+ 'Formule 1' => 'sport/formule-1',
+ 'Wielrennen' => 'sport/wielrennen',
+ 'Schaatsen' => 'sport/schaatsen',
+ 'Tennis' => 'sport/tennis',
+ ],
+ ]
+ ]
+ ];
+
+ public function collectData()
+ {
+ $url = sprintf('https://www.nos.nl/%s', $this->getInput('topic'));
+ $dom = getSimpleHTMLDOM($url);
+ $dom = $dom->find('ul.list-items', 0);
+ if (!$dom) {
+ throw new \Exception(sprintf('Unable to find css selector on `%s`', $url));
+ }
+ $dom = defaultLinkTo($dom, $this->getURI());
+ foreach ($dom->find('li.list-items__item') as $article) {
+ $a = $article->find('a', 0);
+ $this->items[] = [
+ 'title' => $article->find('h3.list-items__title', 0)->plaintext,
+ 'uri' => $article->find('a.list-items__link', 0)->href,
+ 'content' => $article->find('p.list-items__description', 0)->plaintext,
+ 'timestamp' => strtotime($article->find('time', 0)->datetime),
+ ];
+ }
+ }
+}