Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: HTTPStripHTML HTTPRecvQuery
;************************************************************************** ; WEB FORM POSTER SAMPLE WINSOCK APP ; ; With this sample app you can find the latest status of a UPS package ; (GroundTrac, 3-day, 2-day, or Next day). Here's how to use it: ; ; 1) Send a package to someone via UPS using any service other than simple ; untracked ground. ; ; 2) Run this script from WinBatch, optionally with 2 params: ; ScanForm.WBT "<your dialup name>" ; ; 4) Enter the number you want to track. This script will send a POST ; request to a CGI script running on UPS' web server. The server will ; return with an HTML page which includes the package's history. ; ; 5) The script will then strip off the page's header & footer information ; and the HTML tags, and then show you the information. ; ; NOTE: This script simulates a user filling out the form at UPS' Package ; Tracking web page: http://www.ups.com/tracking/tracking.html. They may ; change the way their form works at any time without notice. (But even ; then, it'll probably still be a simple format like the current one.) ; ; Author: Jennifer Palonus (GDI) ; ; Date Major changes ; ------- ---------------------------------------------------------------- ; 05apr96 Cloned from WILScanMail.wbt. ; 30apr96 Last changed. ; jan2001 updated for UPS website changes (author of update DRD) ;************************************************************************** sTitle = "TrackUPS" sViewer = "Viewer" sDial = "%param1%" sWebServer = "wwwapps.ups.com" sCGIPath = "/etracking/tracking.cgi" AddExtender ("wwwsk34I.dll") ;Dial our host, asking first if user has more than 1 defined... hConn = 0 sDialUps = DUNItemize () if (ItemCount(sDialUps,@TAB) == 1) sDial = sDialUps else sDial = AskItemList ("Choose a dial-up connection", sDialUps, @TAB, @SORTED, @SINGLE) endif hConn = DUNConnect (sDial) nErr = wxGetLastErr() if (!hConn) select (nErr) case @SErrBusy Message (sTitle, "Couldn't connect to %sDial%: Line busy.") break case @SErrNoAnswer Message (sTitle, "Couldn't connect to %sDial%: No answer.") break case @SErrVoice Message (sTitle, "Couldn't connect to %sDial%: A human answered.") break case nErr Message (sTitle, "Couldn't connect to %sDial%: Error %nErr%.") end select exit endif ; This is our "browser"... if (!WinExist (sViewer)) Run ("notepad.exe","%sViewer%.") if (WinExistChild("Notepad", "Cannot find the %sViewer%")) SendKeysChild ("Notepad", "Cannot find the %sViewer%", "~") endif WinTitle ("%sViewer% - Notepad", sViewer) SendKeysTo (sViewer, "!ew") ; Turn on word-wrap else ; Clear the existing browser window... SendKeysTo (sViewer, "!ea{del}") endif SendKeysTo (sViewer, "---------------------------------------~") ; Get information & log on... sPkgNum = " " while (sPkgNum != "") ; Get the package #... dlgTrackUPSFormat=`WWWDLGED,5.0` dlgTrackUPSCaption=`TrackUPS` dlgTrackUPSX=52 dlgTrackUPSY=70 dlgTrackUPSWidth=166 dlgTrackUPSHeight=44 dlgTrackUPSNumControls=4 dlgTrackUPS01=`6,6,60,DEFAULT,STATICTEXT,DEFAULT,"Tracking number:"` dlgTrackUPS02=`66,6,92,DEFAULT,EDITBOX,edPkgNum,""` dlgTrackUPS03=`26,24,50,DEFAULT,PUSHBUTTON,DEFAULT,"OK",1` dlgTrackUPS04=`86,24,50,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel",2` nRet=Dialog("dlgTrackUPS") if (nRet == 2 || edPkgNum=="") goto HangUp endif ; Post the CGI query... sPkgNum = URLEncode (edPkgNum) sQuery = "http://wwwapps.ups.com/etracking/tracking.cgi?tracknums_displayed=5&TypeOfInquiryNumber=T&HTMLVersion=4.0&sort_by=status&InquiryNumber1=%sPkgNum%" sPage = HTTPRecvQuery (sWebServer, sCGIPath, sQuery, 32767, @HMethodPost) nErr = wxGetLastErr() if (nErr != @SOK) Message (sTitle, "Error receiving web page: %nErr%") break endif ; Trim off everything before "" & after ""... nStart = strindexNC (sPage, "TRACKING NUMBER", 1, @FWDSCAN) + 8 nEnd = strindexNC (sPage, "Tracking results provided by UPS:", nStart, @FWDSCAN) sPage = strsub (sPage, nStart, nEnd-nStart) sPage = strtrim (sPage) ; Finally, strip off all the HTML tags... sPage = HTTPStripHTML (sPage) sPage= strReplace(sPage," ","") ; Message (sTitle, sPage) ClipPut (sPage) SendKeysTo (sViewer, "^v~") SendKeysTo (sViewer, "---------------------------------------~") Drop (sPage) endwhile ; User hit Cancel... :Cancel ; Hang up... :HangUp if (hConn) nRet = DUNDisconnect (hConn) endif exit
Article ID: W12635
Filename: Get Status of UPS Package.txt
File Created: 2001:03:01:15:11:26
Last Updated: 2001:03:01:15:11:26