Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TomsToucheBridge] Add new bridge #4438

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions bridges/TomsToucheBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

class TomsToucheBridge extends BridgeAbstract
{
const NAME = 'Toms Touché';
const URI = 'https://taz.de/#!tom=tomdestages';
const DESCRIPTION = 'Your daily dose of Toms Touche.';
const MAINTAINER = 'latz';
const CACHE_TIMEOUT = 3600; // 1h

public function collectData()
{
$url = 'https://taz.de/';
$html = getSimpleHTMLDOM($url); // Docs: https://simplehtmldom.sourceforge.io/docs/1.9/index.html
$date = $html->find('p[x-ref]');
$date = trim($date[0]->innertext);
[$day, $month, $year] = explode('.', $date);
$image = $html->find('img[alt="tom des tages"]');

$item = [];
$item['title'] = "Toms Touché - $date";
$item['uri'] = 'https://taz.de/#!tom=tomdestages';
$item['timestamp'] = mktime(0, 0, 0, $month, $day, $year);
$item['content'] = $image[0] . '</img>'; // This isn't good HTML style, but at least syntactically correct
$item['uid'] = $image[0]->getAttribute('src');
$this->items[] = $item;
}
}