changeset 350:51c08336d7b1

feeds: Add support for Poliisi.fi information reports.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 01 Nov 2015 22:05:25 +0200
parents f7793ef7c925
children 0f55bbb7fea3
files fetch_feeds.tcl
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/fetch_feeds.tcl	Sun Nov 01 22:04:45 2015 +0200
+++ b/fetch_feeds.tcl	Sun Nov 01 22:05:25 2015 +0200
@@ -190,6 +190,23 @@
 }
 
 
+### Poliisi tiedotteet
+proc fetch_poliisi { datauri dataname dataprefix } {
+  if {![fetch_dorequest $datauri ustatus uscode ucode upage umeta]} {
+    return 0
+  }
+
+  set umatches [regexp -all -nocase -inline -- "<div class=\"channelitem\"><div class=\"date\">(.*?)</div><a class=\"article\" href=\"(\[^\"\]+)\">(\[^<\]+)</a>" $upage]
+  set nmatches [llength $umatches]
+  for {set n 0} {$n < $nmatches} {incr n 4} {
+    set stmp [string trim [lindex $umatches [expr $n+3]]]
+    add_entry $dataname $dataprefix [lindex $umatches [expr $n+2]] "[lindex $umatches [expr $n+1]]: $stmp"
+  }
+}
+
+
+
+
 ### Open database, etc
 set nitems 0
 set currclock [clock seconds]
@@ -201,6 +218,8 @@
 
 
 ### Fetch the feeds
+fetch_poliisi "http://www.poliisi.fi/oulu/tiedotteet/1/0?all1/0" "Poliisi/Oulu" "http://www.poliisi.fi"
+
 fetch_halla_aho
 
 fetch_adventurers