summaryrefslogtreecommitdiffstats
path: root/util/bin/vvs.de
diff options
context:
space:
mode:
authormakefu <root@pigstarter.de>2013-11-04 16:49:33 +0100
committermakefu <root@pigstarter.de>2013-11-04 16:49:33 +0100
commit02cb0cc2f320a43161a21d612d6df1e9620b5fc0 (patch)
treeb02eaa1358c3eaee4dcddabd83045f4705998a95 /util/bin/vvs.de
parent11d255a4b21cd90221cf1ed15a96d249cf72ef1d (diff)
parent52dc574f7a526661661255fc6e65640802609808 (diff)
Merge branch 'master' of https://github.com/krebscode/painload
Diffstat (limited to 'util/bin/vvs.de')
-rwxr-xr-xutil/bin/vvs.de61
1 files changed, 61 insertions, 0 deletions
diff --git a/util/bin/vvs.de b/util/bin/vvs.de
new file mode 100755
index 00000000..718f34ce
--- /dev/null
+++ b/util/bin/vvs.de
@@ -0,0 +1,61 @@
+#! /bin/sh
+#
+# NAME
+# vvs.de - web scraper for VVS departure information
+#
+# SYNOPSIS
+# vvs.de ORIGIN DESTINATION
+#
+# EXAMPLES
+# $ vvs.de Hauptbahnhof Renningen
+#
+# CAVEATS
+# Acceptable operands have to be found by trial and error.
+#
+# BUGS
+# Probably bit rot.^_^
+#
+# SEE ALSO
+# mobile.vvs.de
+#
+# COPYRIGHT
+# All departure information is copyrighted by Verkehrs- und
+# Tarifverbund Stuttgart GmbH. The original copyright statement can
+# be obtained online at http://www.vvs.de/impressum .
+#
+# The following code is your fault.
+#
+set -euf
+
+# <form action="./efaanyfield/anyfield.php" method="post" id="efaForm">
+ #s/itdDateDay=/&${3-$itdDateDay}/
+ #s/itdDateMonth=/&${4-$itdDateMonth}/
+ #s/itdDateYear=/&${5-$itdDateYear}/
+
+vvs_tmp=/tmp/vvs.tmp
+curl -Ss http://www.vvs.de/fahrplan/ |
+sed -rn "/<!-- EFA -->/,/<!-- \/EFA -->/{
+ s.*<input.*name=\"([^\"]*)\".*value=\"([^\"]*)\".*/>.*\1=\2;T
+ /itdTripDateTimeDepArr=arr/b
+ s/(name_origin=).*/\1${1-$name_origin}/
+ s/(name_destination=).*/\1${2-$name_destination}/
+ ${3+s/(itdTimeHour=).*/\1${3-$itdTimeHour}/}
+ ${4+s/(itdTimeMinute=).*/\1${4-$itdTimeMinute}/}
+ p
+}" | tr '\n' '&' | sed 's/&$//' >"$vvs_tmp"
+
+
+#while read line ; do
+# test -z "$line" || echo "$line"
+#done >"$vvs_tmp"
+
+echo from: ${1-$name_origin}
+echo \ \ to: ${2-$name_destination}
+echo '-------------------------------------'
+w3m -cols 9423 -post "$vvs_tmp" \
+ -dump http://www.vvs.de/./efaanyfield/anyfield.php |
+sed -rn "
+ s/^ +[0-9]+ +([0-9]+:[0-9]+) +([0-9]+:[0-9]+) +([A-Z0-9 ,]+) .*$/\1 \2 \3/p
+" | tr -d ,
+
+####