-
Notifications
You must be signed in to change notification settings - Fork 0
/
stv.php
26 lines (19 loc) · 721 Bytes
/
stv.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
declare(strict_types=1);
use theodorejb\PhpStv\WikiParser;
require 'vendor/autoload.php';
$cacheFilename = 'stv_cache.html';
$rfcUrl = 'https://wiki.php.net/rfc/shorter_attribute_syntax_change';
if (!file_exists($cacheFilename)) {
echo "Reading from {$rfcUrl}..." . PHP_EOL;
$html = WikiParser::getHtml($rfcUrl);
echo 'Updating cache...' . PHP_EOL;
$result = @file_put_contents($cacheFilename, $html);
if ($result === false) {
throw new Exception('Failed to update cache');
}
}
echo "Reading from {$cacheFilename}..." . PHP_EOL . PHP_EOL;
$html = WikiParser::getHtml($cacheFilename);
$election = WikiParser::getStvElection($html);
echo $election->getResultsHtml(true, false);