I'm trying to extract price from a website by using ie.doc.innertext and asterisk but its not working.
For example, the price in innertext is: "Cart Total: $25"
My condition is: If the words "Item added to the cart" exist in innertext and "Cart Total" exist in innertext, then extract the part after colon in the innertext Cart Total: $25
It's $25 which I want.
My code is:
Sub GetPrice()
Dim IE As New InternetExplorer
Dim doc As HTMLDocument
IE.Visible = True
IE.Navigate " http://www.example.com"
Do Until IE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Set doc = IE.Document
doc.forms("shipform").Elements("upcs").Value = "025192197925"
Application.Wait Now + TimeValue("00:00:01")
doc.forms("shipform").Elements("submit").Click
Do Until IE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Application.Wait Now + TimeValue("00:00:01")
html_code = doc.body.innerText
If InStr(html_code, "Item added to the cart") > 0 Then
If InStr(html_code, "Cart Total " & "*") > 0 Then
the_string = Right("Cart Total " & "*", 15)
MsgBox the_string
End If
ElseIf InStr(html_code, "Item not added") > 0 Then
MsgBox "Not added"
End If
Set IE = Nothing
End Sub
I'd highly appreciate your help. Thank you