changeset 6:026257a62da4

ruoka: Some fixes, does not work with the new Amica lists tho.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 22 Jun 2011 19:57:02 +0300
parents 5ac4fd6d011a
children 50b52294e93e
files hae_ruoka.tcl
diffstat 1 files changed, 20 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hae_ruoka.tcl	Wed Jun 22 19:56:31 2011 +0300
+++ b/hae_ruoka.tcl	Wed Jun 22 19:57:02 2011 +0300
@@ -86,14 +86,16 @@
 
   set upage [::http::data $utoken]
   ::http::cleanup $utoken
-  
+
   set nmatches 1
   while {$nmatches > 0} {
-    set umatches [regexp -nocase -inline -- "<span class='otsikko'>(Maanantai|Tiistai|Keskiviikko|Torstai|Perjantai|Lauantai|Sunnuntai) +(\[^<\]+)</span>(.*)\$" $upage]
+#    set umatches [regexp -nocase -inline -- "<span class='otsikko'><b>(Maanantai|Tiistai|Keskiviikko|Torstai|Perjantai|Lauantai|Sunnuntai) \[0-9\]+\.\[0-9\]+</b></span><P>(\[^<\]+)</span>(.*)\$" $upage]
+    set umatches [regexp -nocase -inline -- "<span class='otsikko'><b>(Maanantai|Tiistai|Keskiviikko|Torstai|Perjantai|Lauantai|Sunnuntai) +\[0-9\]+\.\[0-9\]+</b></span>(.*?)</span>(.*)$" $upage]
     set nmatches [llength $umatches]
+    puts "[lindex $umatches 1]"
     if {$nmatches > 3} {
-      set umat [regexp -nocase -inline -- "^(.+?)<br /><br /><br />" [lindex $umatches 3]]
-      set umat [regexp -all -nocase -inline -- "(.\*\?)<br>" [lindex $umat 1]]
+#      set umat [regexp -nocase -inline -- "^(.+?)<br>" [lindex $umatches 3]]
+      set umat [regexp -all -nocase -inline -- "(.\*\?)<br>" [lindex $umatches 2]]
       set tmp ""
       foreach {ukey udata} $umat {
         set item [string trim [convert_ent $udata]]
@@ -111,18 +113,24 @@
 
 
 ##############################################################################
+set kello [clock seconds]
+set viikko [expr [clock format $kello -format "%W"] + 1]
+set vuosi [clock format $kello -format "%Y"]
+
 # Amica/OAMK tekniikan yksikkö
 add_amica "http://www.amica.fi/kotkanpoika" "OAMK"
 
 # Oulun yliopiston Unirestat
-add_uniresta "http://www.uniresta.fi/uniresta.php?ruokalista=2"  "Aularavintola"
-add_uniresta "http://www.uniresta.fi/uniresta.php?ruokalista=3"  "Discus"
-add_uniresta "http://www.uniresta.fi/uniresta.php?ruokalista=4"  "Julinia"
-add_uniresta "http://www.uniresta.fi/uniresta.php?ruokalista=5"  "Kastari"
-add_uniresta "http://www.uniresta.fi/uniresta.php?ruokalista=6"  "Snellmania"
-add_uniresta "http://www.uniresta.fi/uniresta.php?ruokalista=7"  "Pruxis"
-add_uniresta "http://www.uniresta.fi/uniresta.php?ruokalista=10" "Vanilla"
-add_uniresta "http://www.uniresta.fi/uniresta.php?ruokalista=11" "Minttu"
+set str "http://www.uniresta.fi/2010/ruokalista_tulostettava.php?viikko=$viikko&vuosi=$vuosi&ravintola"
+
+add_uniresta "$str=2"  "Aularavintola"
+add_uniresta "$str=3"  "Discus"
+add_uniresta "$str=4"  "Julinia"
+add_uniresta "$str=5"  "Kastari"
+add_uniresta "$str=6"  "Snellmania"
+add_uniresta "$str=7"  "Pruxis"
+add_uniresta "$str=10" "Vanilla"
+add_uniresta "$str=11" "Minttu"
 
 
 ##############################################################################