hsingh2088
New Member
- Joined
- May 6, 2011
- Messages
- 35
I am working on a grad school project analyzing the average prices for used luxury cars in Houston. So far, I have been able to develop the following macro.
I am trying to extract price, make, model, year and miles.
I get the a bunch of HTML output which contains the data I am searching for but can't figure out how I narrow it down just to the attributes listed above and paste it into my Excel document properly. I am close! I just need a little help getting it across the finish line...
I am trying to extract price, make, model, year and miles.
Code:
Private Sub CommandButton1_Click()
Sheet9.WebBrowser1.Navigate (Sheet9.Range("K2"))
Do
DoEvents
Loop Until Sheet9.WebBrowser1.ReadyState = READYSTATE_COMPLETE
UserForm1.TextBox1.Text = Sheet9.WebBrowser1.Document.Body.InnerTEXT
'5650
the_html_code = Sheet9.WebBrowser1.Document.Body.InnerHTML
'If InStr(the_html_code, "<span class="prices") > 0 Then MsgBox "ok"
the_output_row = 1
Do
DoEvents
start_of_value = InStr(the_html_code, "itemprop=")
If start_of_value > 0 Then
the_output_row = the_output_row + 1
the_url = Mid(the_html_code, start_of_value + 6, Len(the_html_code))
the_html_code = Mid(the_html_code, start_of_value + 6, Len(the_html_code))
the_url = Mid(the_url, 1, InStr(the_url, Chr(36)))
Sheet8.Range("A" & the_output_row) = the_url
End If
Loop Until start_of_value = 0
MsgBox "Complete"
End Sub
I get the a bunch of HTML output which contains the data I am searching for but can't figure out how I narrow it down just to the attributes listed above and paste it into my Excel document properly. I am close! I just need a little help getting it across the finish line...