-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext_bus.pl
executable file
·28 lines (23 loc) · 1.05 KB
/
next_bus.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env perl
# set stops to the bus stop numbers you like and buses to helpful bus numbers.
@stops = (2002, 2893);
@buses = (4, 6, 106);
$buses = join "|",@buses;
$url = "http://www.edmonton.ca/portal/server.pt/gateway/PTARGS_0_0_341_239_0_43/http%3B/AppServer/ExternalSupported/Transit/BusStopSchedule_Results.aspx";
($date = `date +%Y+%b+%d`) =~ s/\n//;
$hour = `date +%k` * 60;
($minute = `date +%M`) =~ s/\n//;
foreach $stop (@stops) {
open WGET, "wget --post-data='__EVENTTARGET=&__EVENTARGUMENT=&txtTravelDate=$date&cboHour=$hour&cboMinute=$minute&txtBusStopNumber=$stop&cmdBusStopScheduleSubmit=Get+Bus+Stop+Schedule' '$url' -O - |";
$buf = "";
while (<WGET>) {
if (/(lblBusStopNumberLabel|lblDateOfTravelLabel|lblLocationLabel|lblDirectionLabel|lblDepartureDate)/) {
/>([^<]*)<\//;
$label = $1;
} elsif (/(lblBusStopNumber|lblDateOfTravel|lblLocation|lblDirection)/ || /lnkRouteNumber/ && />($buses)</) {
/>([^<]*)<\//;
$buf .= "$label $1\n";
}
}
print $buf
}