diff --git a/DVB-Scraping.mw b/DVB-Scraping.mw index f78f6ba8..a332355d 100644 --- a/DVB-Scraping.mw +++ b/DVB-Scraping.mw @@ -256,6 +256,22 @@ station=${@:-Mockritzer Strasse} awk -vRS='\\],\\[|\r\n\r\n' -vFS='"(,")*' -vstation="${station/ /%20}" 'BEGIN { s="/inet/tcp/0/widgets.vvo-online.de/80"; print "GET /abfahrtsmonitor/Abfahrten.do?ort=Dresden&hst=" station "&vz=5 HTTP/1.1\r\nHost: widgets.vvo-online.de\r\nAccept: */*\r\nConnection: close\r\n\r\n" |& s; print "Nr. Min. Richtung"; while (s |& getline) { if ($0 ~ /quot/) { printf ("%3s %4s %s\n", $2, $4, $3); } } }' | perl -npe 's/&#(\d*);/($1 & ~0x7f ? chr(0xc0 | (($1 >> 6) & 0x3f)).chr(0x80 | ($1 & 0x3f)) : chr($1))/eg' +Und so sieht es aus: + +$ ./pnv +Nr. Min. Richtung + 75 6 Pirnaischer Pl. + 13 10 Mickten + 13 11 Prohlis + 75 12 Leubnitzer Höhe + 9 13 Prohlis + 9 13 Kaditz + 9 14 Kaditz + 75 15 Messe Dresden + 89 15 Löbtau + 9 15 Prohlis + + 2.) DVB Routenplanung, Usage: ./t [destination [station]] (z.B. `./t "Max Muster Strasse" HBF', `./t HBF' oder `./t') #!/bin/bash @@ -265,6 +281,32 @@ srcstation=${2:-My default station} awk -vrequest="http://efa.vvo-online.de:8080/dvb/XSLT_TRIP_REQUEST2?sessionID=0&requestID=0&language=de&usage=xslt_trip&execInst=normal&command=&ptOptionsActive=-1&itOptionsActive=&itDateDay=`date +%d`&itDateMonth=`date +%m`&itDateYear=`date +%y`&place_origin=Dresden&placeState_origin=empty&type_origin=stop&name_origin=${srcstation/ /%20}&nameState_origin=empty&place_destination=Dresden&placeState_destination=empty&type_destination=stop&name_destination=${dststation/ /%20}&nameState_destination=empty&itdTripDateTimeDepArr=dep&itdTimeHour=`date +%H`&idtTimeMinute=`date +%M`" -vRS="]*>|" -vFS=']*>||\\("|"\\)' 'BEGIN { isDest=0; route=0; curr=0; s="/inet/tcp/0/efa.vvo-online.de/8080"; print "GET " request " HTTP/1.1\r\nHost: efa.vvo-online.de\r\nUser-Agent: akts!zr\r\nAccept: */*\r\nConnection: close\r\n\r\n" |& s; while (s |& getline) { if($0 ~ /option value="[0-9]+:[0-9]+"/) { if($0 ~ /name_destination/) isDest = 1; split($0, a, /]*>|<\/option>/); if(isDest) for(pos = 2; a[pos]; pos += 2) dest = dest (dest ? ", " : "") a[pos]; else for(pos = 2; a[pos]; pos += 2) src = src (src ? ", " : "") a[pos]; continue; } if($0 ~ /#ROUTE/) { split($0, a, /]*>|<\/a>/); routes[++route]=a[2]; continue; } if($0 ~ /"ROUTE_[0-9]"/) { print routes[++curr]; print " Zeit Linie Station"; continue; } if($2 ~ /^[0-9][0-9]:[0-9][0-9]/) { split($11, a, / /); line=a[2]; printf (" %s %5s %s\n", $2, line, $4 " " $6); } } if(src || dest) { print "Gehts etwas genauer?"; if(src) print "Einstieg: " src "?"; if(dest) print "Ausstieg: " dest "?"; } }' | perl -npe 's/([\x80-\xff])/(chr(0xc0 | ((ord($1) >> 6) & 0x3f)).chr(0x80 | (ord($1) & 0x3f)))/eg' +Und so sieht es aus: + +$ ./t Terminal Mock +Gehts etwas genauer? +Einstieg: Campingplatz Mockritz, Mockethaler Straße, Mockritz, Mockritzer Straße? +$ ./t Terminal "Mockritzer Str" +1. Fahrt am 01.12.2008 18:40 - 19:44 Uhr + Zeit Linie Station + 18:40 13 ab Dresden Mockritzer Straße + 19:02 an Dresden Bischofsweg + 19:05 7 ab Dresden Bischofsweg + 19:16 an Dresden Infineon Nord + 19:26 77 ab Dresden Infineon Nord + 19:32 an Dresden Flughafen +2. Fahrt am 01.12.2008 19:05 - 19:49 Uhr + Zeit Linie Station + 19:05 75 ab Dresden Mockritzer Straße + 19:08 an Dresden Hp Strehlen + 19:13 S ab Dresden-Strehlen + 19:40 an Dresden Flughafen + 19:48 77 ab Dresden Flughafen + 19:49 an Dresden Flughafen Terminal 1 +3. Fahrt am 01.12.2008 19:05 - 19:57 Uhr +... + + =Python= ==CLI-Interface==