Using Excel VBA code to send a POST and retrieve data

Viewed 12093

What VBA code would allow me to send a POST request (in a asp search box) and then to retrieve data between a <span id="xxx"></span> tag? (in the resulting page)

I have the following code that simulates a search request in the page:

 Dim Site As Object
 Set Site = CreateObject("InternetExplorer.application")
 Dim QNUMBER As String
 Dim URL As String

 URL = "apps/inventory/Default.aspx" 'local website
 QNUMBER = textBox_Scan.Text
 Site.navigate URL
 While Site.busy
 Wend
 Dim oHTMLDoc As Object
 Set oHTMLDoc = Site.document

 oHTMLDoc.getElementById("input_search").Value = QNUMBER
 oHTMLDoc.getElementById("btn_search").Click

It doesnt feel "clean" to do it that way and I feel that sending a POST request would be more appropriate.

Thanks.

[edit]

This is the form code

 <form name="aspnetForm" method="post" action="Default.aspx" id="aspnetForm">

The input text id

id="input_search" 

The submit button code

id="btn_search"

and I'd like to get data from <span id="warranty">36 month</span> and <span id="budget">500$</span>

1 Answers
Related