PDA

View Full Version : Http - stumbling block



stanl
10-22-2005, 07:05 AM
As part of a larger project to create spreadsheets with pricelists for publications from various sources, using a huge Title/ISBN Access lookup the goal was to use the WinHttp.WinHttpRequest.5.1 ActiveX Object which comes with XP and 2000. An alternative would be MSXML2.XMLHTTP.4.0 but that appears to require a separate download and install. The below code illustrates a problem (URL is hard-coded for the example) with 5.1 - curious 5.1 does not include a ResponseXML.xml property - which MSXML2 has, though not needed to work. Can anyone suggest a way to get 5.1 to return a response without error? TIA Stan




Sub HttpRequest()
Dim oHTTP, cURL
cURL = "http://www.chapters.indigo.ca/item.asp?"
cURL = cURL & "Catalog=books&Item=978089957726"

'test Http GET request with 2 Microsoft Objects
'should return results if run as is with MSXML - but
'try it with 5.1

'uncomment the WinHttp Object for Unicode error
'Set oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")


'comment next line if testing for unicode error
Set oHTTP = CreateObject("MSXML2.XMLHTTP.4.0")

'same code - either object
oHTTP.Open "GET", cURL, False
oHTTP.SetRequestHeader "Content-Type", "text/xml"
oHTTP.Send ""
MsgBox oHTTP.ResponseText
oHTTP = 0
End Sub

mdmackillop
10-22-2005, 07:28 AM
Hi Stan
This is a bit beyond me in any case, but when I tried to run the code, it appears I'm missing a reference. What references do you have running?
MD

stanl
10-22-2005, 08:04 AM
Thank you for your interest. I attached a screenshot of my refs, though I wonder if it might not be an issue with Objects being registered. If you do get it to work, the URL should give back a response that the requested book could not be found - but you will notice the error is in French and English - which is where I suspect the Unicode error comes in. Substitute this URL:



cURL="http://www.chapters.indigo.ca/item.asp?"
cURL= cURL & "Item=978047174048&Catalog=Books&N=35+528447&Lang=en&Section=books&zxac=1"


Which is a book on Federal Audits. The data of interest would be parsing the classcode for "ourprice"



<tr>
<td class="ourprice">Our Price:</td>
<td class="ourprice">$97.99</td>
</tr>



Stan