Reputation: 25
Below is some code I tried to get the value from a node in webpage. But it fails when trying to set the objNode... any help gratefully appreciated.
Dim objHttp, sWebPage, objNode, objDoc
Set objDoc = CreateObject("MSXML2.DOMDocument")
objDoc.Load "http://www.hl.co.uk/shares/shares-search-results/a/aveva-group-plc-ordinary-3.555p"
' objDoc.setProperty "SelectionLanguage", "XPath"
' Find a particular element using XPath:
Set objNode = objDoc.selectSingleNode("span[@id='ls-bid-AVV-L']")
MsgBox objNode.getAttribute("value")
Upvotes: 1
Views: 2905
Reputation: 38745
objDoc.validateOnParse = False
and avoid problems with monster pages with objDoc.async = False
(at least no "msxml3.dll: The data necessary to complete this operation is not yet available." error).objNode.text
.Upvotes: 3
Reputation: 200293
Use the Internet Explorer COM object:
url = "http://www.hl.co.uk/shares/shares-search-results/a/aveva-group-plc-ordinary-3.555p"
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate url
While ie.ReadyState <> 4
WScript.Sleep 100
Wend
MsgBox ie.document.getElementById("ls-bid-AVV-L").innerText
ie.Quit
Upvotes: 1