changeset 24:1b8260151e99

Get updates / data from upcoming work-in-progress timetables for next period also.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 16 Mar 2011 08:49:49 +0200
parents b4b86915ae2c
children a076d8d22422
files update.sh
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/update.sh	Mon Feb 14 23:55:09 2011 +0200
+++ b/update.sh	Wed Mar 16 08:49:49 2011 +0200
@@ -1,16 +1,18 @@
 #!/bin/sh
-URLPREFIX="http://www.oamk.fi/tyojarjestykset/otek/luokat/"
 URLSUFFIX=".htm"
 CACHEDIR="cache/"
-LISTFILE="luokat.tmp"
-CLASSFILE="luokat.txt"
 
+function parse()
+{
+URLPREFIX="$1"
+CLASSFILE="$2"
+LISTFILE="$2.tmp"
 
 if wget -q -O "$LISTFILE" "$URLPREFIX"; then
 	perl -ne 'if (/<a href="OR_([A-Z]{3}\d\S+)\.htm">/) { print "$1\n"; }' < "$LISTFILE" > "$CLASSFILE"
 fi
 
-
+if test -e "$CLASSFILE"; then
 cat "$CLASSFILE" | while read i; do
 	parse=no
 	INFILE="${CACHEDIR}${i}.html"
@@ -49,4 +51,8 @@
 		perl parsedata.pl -php "$INFILE" -o "$OUTFILE"
 	fi
 done
+fi
+}
 
+parse "http://www.oamk.fi/tyojarjestykset/otek/luokat/" "luokat.txt"
+parse "http://www.oamk.fi/~heikkim/riihi4/luokat/" "luokat_next.txt"