0
我很努力地檢索一組鏈接到一個集合。所有其他頁面元素都響應正常的get命令,除了這些。這是知識的HTML和JavaScript將支付股息。我自己的猜測是,錯誤很可能是因爲href是一個javascript命令,或者它們隱藏在「清除」或「清除修補程序」類後面,使它們隱藏起來? 我的最終目標是能夠從JavaScript hrefs內部獲取鏈接。HTML錨榆樹的隱藏到VBA
任何幫助表示讚賞。謝謝
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個每頁。