Bullion price refers to the price related to the refined and stamped weight of the precious metal. The automated IVR is introduced to get the latest bullion prices of gold, silver, platinum, palladium, etc at your fingertip. The Bullion prices listed on the related website are representative only and are subject to change based upon market conditions. Hence, to keep up with the latest market price, it is necessary for the user to perform HTML parsing updations regularly. The sample given below demonstrates how to screen scrape information from a website.
Download the evaluation version of Xtend IVR and install the telephony application in your system. Run the sample script from the Script Editor. Click here to refer the code.
The automated attendant will work as given below:
MAIN: display "Waiting for call . . ." answer 1 play "welcome.wav" play "pleasewait.wav" wait 0 play "music.wav" play "music.wav" play "music.wav" GET_WEB: display "Connecting to http://www.kitco.com/market/" $status = http("http://www.kitco.com/market/") clear if $status != 1 play "tryagain.wav" goto BYE endif $str = $http.Page $ctr = 1 play "newyork.wav" while $ctr <= 4 if $ctr == 1 $link = "/livegoldnewyork" else if $ctr == 2 $link = "/livesilver" else if $ctr == 3 $link = "/liveplatinum" else if $ctr == 4 $link = "/livepalladium" endif $index = find($str,$link) if $index == -1 log "The html report format has been changed. Please rework your parsing routines." play "down.wav" goto BYE endif $index += len($link) $str = mid($str,$index) $index = find($str,"<td><p>") if $index == -1 log "The html report format has been changed. Please rework your parsing routines." play "down.wav" goto BYE endif $index += len("<td><p>") $str = mid($str,$index) $index = find($str,"</td>") $mdate = mid($str,0,$index) $str = mid($str,$index) $index += len("</td>") $str = mid($str,$index) $index = find($str,"<td><p>") if $index == -1 log "The html report format has been changed. Please rework your parsing routines." play "down.wav" goto BYE endif $index += len("<td><p>") $str = mid($str,$index) $index = find($str,"</td>") $mtime = mid($str,0,$index) $str = mid($str,$index) $index += len("</td>") $str = mid($str,$index) $index = find($str,"<td><p>") if $index == -1 log "The html report format has been changed. Please rework your parsing routines." play "down.wav" goto BYE endif $index += len("<td><p>") $str = mid($str,$index) $index = find($str,"</td>") $mbid = mid($str,0,$index) $str = mid($str,$index) $index += len("</td>") $str = mid($str,$index) $index = find($str,"<td><p>") if $index == -1 log "The html report format has been changed. Please rework your parsing routines." play "down.wav" goto BYE endif $index += len("<td><p>") $str = mid($str,$index) $index = find($str,"</td>") $mask = mid($str,0,$index) $str = mid($str,$index) $index += len("</td>") $str = mid($str,$index) $index = find($str,"<td><p>") if $index == -1 log "The html report format has been changed. Please rework your parsing routines." play "down.wav" goto BYE endif $index += len("<td><p>") $str = mid($str,$index) $index = find($str,"</td>") $mlow = mid($str,0,$index) $str = mid($str,$index) $index += len("</td>") $str = mid($str,$index) $index = find($str,"<td><p>") if $index == -1 log "The html report format has been changed. Please rework your parsing routines." play "down.wav" goto BYE endif $index += len("<td><p>") $str = mid($str,$index) $index = find($str,"</td>") $mhigh = mid($str,0,$index) $str = mid($str,$index) $index += len("</td>") $str = mid($str,$index) if $ctr == 1 $metal = "Gold" else if $ctr == 2 $metal = "Silver" else if $ctr == 3 $metal = "Platinum" else if $ctr == 4 $metal = "Palladium" endif endif endif endif play $metal play "date.wav" play Date2Wav(date.Convert($mdate,"MMDDYYYY","DDMMYYYY")) play "time.wav" play Time2Wav($mtime) play "bid.wav" play Num2Wav($mbid) play "ask.wav" play Num2Wav($mask) play "low.wav" play Num2Wav($mlow) play "High.wav" play Num2Wav($mhigh) display $metal ". Date: " $mdate ". Time: " $mtime ". Bid: " $mbid ". Ask: " $mask ". Low: " $mlow ". High: " $mhigh wait 0 $ctr += 1 endwhile BYE: play "thanku.wav" hangup goto MAIN ONHANGUP: hangup goto MAIN ONSYSTEMERROR: log $Error display $Error hangup goto MAIN MAIN: answer 1 $metal.1 = "Gold" $metal.2 = "Silver" $metal.3 = "Platinum" $metal.4 = "Palladium" $link.1 = "/livegoldnewyork" $link.2 = "/livesilver" $link.3 = "/liveplatinum" $link.4 = "/livepalladium" play "welcome.wav" play "pleasewait.wav" wait 0 play "music.wav" play "music.wav" play "music.wav" GET_WEB: $status = http("http://www.kitco.com/market/") clear if $status != 1 speak "no connection try later" goto BYE endif SetVariable("$str",$http.Page) $ctr = 1 play "newyork.wav" while $ctr <= 4 $xlink = format("$link.%d",$ctr) $index = find($str,$$xlink) if $index == -1 log "The html report format has been changed. Please rework your parsing routines." speak "This service is temporarly not available. Please try after some time." goto BYE endif $index += len($$xlink) $str = mid($str,$index) $mdate = GetNextField() $mtime = GetNextField() $mbid = GetNextField() $mask = GetNextField() $mlow = GetNextField() $mhigh = GetNextField() $xmetal = format("$metal.%d",$ctr) play $$xmetal play "date.wav" play Date2Wav(date.Convert($mdate,"MMDDYYYY","DDMMYYYY")) play "time.wav" play Time2Wav($mtime) play "bid.wav" play Num2Wav($mbid) play "ask.wav" play Num2Wav($mask) play "low.wav" play Num2Wav($mlow) play "High.wav" play Num2Wav($mhigh) display $$xmetal ". Date: " $mdate ". Time: " $mtime ". Bid: " $mbid ". Ask: " $mask ". Low: " $mlow ". High: " $mhigh wait 0 $ctr += 1 endwhile BYE: Speak "thank you for using this service" hangup goto MAIN function GetNextField() $index = find($str,"<td><p>") if $index == -1 log "The html report format has been changed. Please rework your parsing routines." speak "This service is temporarly not available. Please try after some time." return "" endif $index += len("<td><p>") SetVariable("$str",mid($str,$index)) $index = find($str,"</td>") $mdata = mid($str,0,$index) SetVariable("$str",mid($str,$index)) $index += len("</td>") SetVariable("$str",mid($str,$index)) return $mdata ONHANGUP: hangup goto MAIN ONSYSTEMERROR: log $Error display $Error hangup goto MAIN