/
structure_commitees.php
90 lines (73 loc) · 1.97 KB
/
structure_commitees.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/*
* RIS Sessions Reader by tranquillo
*
* Das Programm ließt den Sitzungskalender der Stadt
* Dresden (Somacos Session RIS) ein.
* Und gibt daraus alle Gremien als Array zurück.
*
* robtranquillo@gmx.de
* twitter.com/robtranquillo
* github.com/robtranquillo
*
* Version 1.0 / 03.09.2015
*
* Licence: public domain with BY (Attribution)
*/
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: text/plain');
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
// link zu den Gremien
$url = 'http://ratsinfo.dresden.de/gr0040.php';
$commitees = get_commitees($url);
print_r($commitees);
/*
* Gremien des Stadtrats ermitteln
*/
function get_commitees($url)
{
$html = get_html($url);
if($html === false) echo 'connection error';
else {
$oldSetting = libxml_use_internal_errors( true );
libxml_clear_errors();
$dom = new DOMDocument();
$dom->loadHtml( $html );
$tbody = $dom->getElementsByTagName('tbody');
$trs = $tbody[0]->getElementsByTagName('tr');
$commitees = array();
foreach( $trs as $tr)
{
$tds = $tr->getElementsByTagName('td');
$link = $tds[0]->getElementsByTagName('a');
if($link->length > 0)
{
$commitee = array(
'name' => $link[0]->nodeValue,
'link' => $link[0]->getAttribute('href')
);
}
$commitees[] = $commitee;
}
libxml_clear_errors();
libxml_use_internal_errors( $oldSetting );
return $commitees;
}
return false;
}
/*
* Funktion um Seiten aus dem Ratsinfo zu ziehen
*/
function get_html($url)
{
$ratsinfo_connector = false;
include('ratsinfo_connect.php');
$ratsinfo_connector = new Ratsinfo();
if( $ratsinfo_connector === false ) return false;
else {
return $ratsinfo_connector->get_url($url);
}
}
?>