magelan
12-27-2012, 08:00 AM
Hi all,
Given a specific website with a modifiable URL
https://tools.usps.com/go/ZipLookupResults...&address2=&city=&state=Select&urbanCode=&postalCode=12345&zip= (https://tools.usps.com/go/ZipLookupResultsAction!input.action?resultMode=2&companyName=&address1=&address2=&city=&state=Select&urbanCode=&postalCode=12345&zip=)
as you can see, you cna modify the getdata for postalcode=xxxxx and put in any zipcode you want. What i need to do is script a program that will run through a list of zipcodes that I have, insert the zipcode into that URL [i think that is the easy part..?] and then pull a specific part of data from the website.
The part that I need is enclosed in a class [i think that makes it easier to pull?] called "std-address" and is that standard line of output that you get from inputting any valid zipcode into the URL. Such as...
<p class="std-address (http://www.vbaexpress.com/forum/)">SCHENECTADY NY</p>
The question is, how do I write the VBA to visit the URL with my given 5 digit zip and then get the city name? Ideally, this would be enclosed in a sub, like..
sub getCityFromZip(zipCode as integer, resultCity as string)
[code to pull up the website with the right zipcode and get the data..
resultCity=the result from above...
end sub
Given a specific website with a modifiable URL
https://tools.usps.com/go/ZipLookupResults...&address2=&city=&state=Select&urbanCode=&postalCode=12345&zip= (https://tools.usps.com/go/ZipLookupResultsAction!input.action?resultMode=2&companyName=&address1=&address2=&city=&state=Select&urbanCode=&postalCode=12345&zip=)
as you can see, you cna modify the getdata for postalcode=xxxxx and put in any zipcode you want. What i need to do is script a program that will run through a list of zipcodes that I have, insert the zipcode into that URL [i think that is the easy part..?] and then pull a specific part of data from the website.
The part that I need is enclosed in a class [i think that makes it easier to pull?] called "std-address" and is that standard line of output that you get from inputting any valid zipcode into the URL. Such as...
<p class="std-address (http://www.vbaexpress.com/forum/)">SCHENECTADY NY</p>
The question is, how do I write the VBA to visit the URL with my given 5 digit zip and then get the city name? Ideally, this would be enclosed in a sub, like..
sub getCityFromZip(zipCode as integer, resultCity as string)
[code to pull up the website with the right zipcode and get the data..
resultCity=the result from above...
end sub