Parking

From SoftIVR

Jump to: navigation, search

Parking

Finding out how many parking spaces there are at 4th and Washington in Ann Arbor requires the extraction of information from an HTML page. We use Javascript's regex functions for this, and the resulting code looks like:

// Parking service - from http://www.voiptechchat.com/voip/218/use-asterisk-cepstral-and-perl-to-get-parking-and-weather-updates/
answer();
say("Please wait a moment..", "en-us-f");
// Get number of parking spaces at 4th and Washington
ps = httpGet('http://www.a2dda.org/parking__transportation/available_parking_spots/');
ps = ps.replace(/[\n\r\t]/g, ''); // Strip out newlines
re = /4th and Washington[^<]*<\/td>[^<]*<td>[^0-9]*([0-9]+).*$/gim;
match = re.exec(ps);
say("There are " + match[1] + " parking spaces at fourth and washington.", "en-us-f");

To test, call 1-253-243-1137.

More howtos.