Web Query - Tim Williams xmlhttp Object

R

ron

I have a number of macros that perform various web queries. I
recently came across a post by Tim Williams from 2006 where he uses
the xmlhttp object approach. It seems so elegant, no need to open IE,
no need to wait for IE to load, no screen-scraping - the returned
information is assigned to a variable for further parsing, etc.

So I'm trying to learn a bit more about how to use this approach. The
following url requires two inputs, a method to search by (I typically
use "Street Name") and a street name (let's use "newport").

http://www.bouldercounty.org/assessor/asrproprecords/assess_input.asp

I've tried the following bit of code within my sub,

Set my_obj = CreateObject("MSXML2.XMLHTTP")
my_obj.Open "GET", "http://www.bouldercounty.org/assessor/
asrproprecords/assess_input.asp", False, "street_name",
"newport"
my_obj.send
my_var = my_obj.responsetext
Set my_obj = Nothing

but it doesn't bring back the source code from the expected (next)
webpage. I know how to achieve this using the web query / ipf.value
method, but I'd like to figure out how to do it using the xmlhttp
object approach. What is the correct way to provide these inputs
using the xmlhttp object approach? Any help would be much
appreciated...TIA, ron
 
T

Tim Williams

The form you're trying to mimic uses POST and not GET. The version below
worked for me.
I still prefer the IE automation method for something like this though: IE
is much better at reliably parsing sometimes "broken" HTML into actual
content.

Tim

'*************************
Sub DoPost()


Const URL As String =
"http://www.bouldercounty.org/assessor/asrproprecords/assess_proplist.asp"

Dim my_obj As Object, sPost

sPost = "prop_search=street_name&search_criteria=newport"

Set my_obj = CreateObject("MSXML2.XMLHTTP")
my_obj.Open "POST", URL, False

my_obj.setRequestHeader "Content-type",
"application/x-www-form-urlencoded"

my_obj.send sPost

Debug.Print my_obj.responseText

Set my_obj = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top