我正在努力将一组链接检索到一个集合中。除了这些之外,所有其他页面元素都响应正常的get命令。这是HTML和JavaScript的知识将带来红利的地方。我自己的猜测是,错误可能与href是一个javascript命令有关,还是它们隐藏在“clear”或“clearfix”类后面,将它们隐藏起来? 我的最终目标是能够从javascript hrefs中删除链接。
感谢任何帮助。谢谢
Public Function getNewsMAIN()
Dim strURL As String: strURL = _
"http://www.londonstockexchange.com/exchange/prices-and-markets/stocks/exchange-insight/company-news.html?fourWayKey=GB00BYN59130GBGBXSTMM"
Dim HTMLDoc As New HTMLDocument
Dim oXMLHTTP As Object
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
oXMLHTTP.Open "GET", strURL, False
oXMLHTTP.send
If oXMLHTTP.Status = 200 Then
HTMLDoc.body.innerHTML = oXMLHTTP.responseText
Else: End If
'//Various attempts at cornering the links
Dim myLinks As IHTMLElementCollection
Dim myLink As IHTMLElement
Set myLinks = HTMLDoc.getElementsByTagName("a") '("ul") ("li")
Set myLinks = HTMLDoc.getElementsByClassName("newsArchive") '("newsContainer")
Set myLink = HTMLDoc.getElementById("newsArchive")
End Function
有问题的HTML。 链接包含在
中<li class="newsContainer"></li>
每页有40个。