Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Zip Code Lookup on USPS
Message
From
19/03/1999 15:13:05
 
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00199870
Message ID:
00199938
Views:
12
>On the US Postal Service site, you can lookup a city based on a zip code passed from the page. You can also lookup a zip code based on a city. What I am trying to guess here is the exact URL to pass (in VFP) including a Zip Code parameter without going to the site itself. I am trying to deduce guesses by looking at the source of the page itself. For example, with Web Connect, I put the name of the function to call, then the parameter(s) separated by tildes [i.e., ~]. If anyone can tell me if this is possible, has anyone done this, what some good guesses would be, I would be most appreciative.
>
>For a start, see:
>
>USPS
>
>then view the frame source.
>
>Many TIA!

I see that yo usolved your problem. But for fufture reference you can do what you were trying to do.

The USPS cgi program only needs to have the form variables it is looking for to be able to process your request and formulate a response.

You could approach it in a couple of ways. First, you could automate IE, have it navigate to that site, fill in the form variable with something like

oIE.Document.Forms(1).ctystzip.value = "78664-1234"

and then sumbmit the request. After waiting for the result, you can parse out the returned SQL to get your city. This is kind of kludgy though, IMHO.

A more graceful way would be to use wwIPStuff.

The code would be something like:

oIP = CREATEOBJECT('wwIPStuff')
oIP.HTTPConnect('www.usps.com')
oIP.AddPostKey('ctyStZip','78664-1234')
lcBuffer = ""
oIP.HTTPGetEx("/cgi-bin/zip4/ctystzip",@lcBUffer)
?lcBuffer

lcBuffer will hold the resulting HTML that you can parse for your city. I got the form action and hte name of the form variable by viewing the source of the USPS search page. I tried it. It works.

I know that you don't need this now, but knowing that this is within your power can open some doors for you.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform