Столкнулась с задачей, которую никак не могу решить.
Дана таблица, в которой по сути нет id у ячеек. Нужно вычепить конкретную ячейку - 2 строка, 3 столбец. Попробуем на живых примерах, нашла аналогичный случай. Вот страница товара: http://russvet.ru/products/5983/926478/ У него есть тех.харакеристики, мне, допустим, нужен на выходе Артикул (именно номер, не само слово, ничего больше не нужно).
Нашла в интернете код, который позволяет выцепить таблицу целиком (прикладываю), но адаптировать его не получилось. Через NextSibling выходит какая-то ерунда (выдает ошибку). Но у меня таких страниц будет очень много; нужен конкретный элемент. Подскажите, пожалуйста, как это можно сделать?
Код
Sub ParseTable()
Dim IE As InternetExplorer
Dim htmldoc As MSHTML.IHTMLDocument 'Document object
Dim eleColtr As MSHTML.IHTMLElementCollection 'Element collection for tr tags
Dim eleColtd As MSHTML.IHTMLElementCollection 'Element collection for td tags
Dim eleRow As MSHTML.IHTMLElement 'Row elements
Dim eleCol As MSHTML.IHTMLElement 'Column elements
Dim ieURL As String 'URL
'Open InternetExplorer
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
'Navigate to webpage
ieURL = "http://russvet.ru/products/5983/926478/"
IE.navigate ieURL
'Wait
Do While IE.Busy Or IE.readyState <> 4
DoEvents
Loop
Set htmldoc = IE.document 'Document webpage
Set eleColtr = htmldoc.getElementsByTagName("tr") 'Find all tr tags
'This section populates Excel
i = 0 'start with first value in tr collection
For Each eleRow In eleColtr 'for each element in the tr collection
Set eleColtd = htmldoc.getElementsByTagName("tr")(i).getElementsByTagName("td") 'get all the td elements in that specific tr
j = 0 'start with the first value in the td collection
For Each eleCol In eleColtd 'for each element in the td collection
Sheets("Sheet1").Range("A1").Offset(i, j).Value = eleCol.innerText 'paste the inner text of the td element, and offset at the same time
j = j + 1 'move to next element in td collection
Next eleCol 'rinse and repeat
i = i + 1 'move to next element in td collection
Next eleRow 'rinse and repeat
IE.Quit
End Sub
Доброе время суток. У меня по ссылке получилось так (с ранним связыванием).
Код
Public Sub test()
Dim pHtml As New MSHTML.HTMLDocument
Dim pHttp As New MSXML2.XMLHTTP60
Dim p As Object
pHttp.Open "GET", "http://russvet.ru/products/5983/926478/"
pHttp.send
pHtml.body.innerHTML = pHttp.responseText
Set p = pHtml.querySelector("div#technical_chars table table").Rows(1)
MsgBox p.Cells(0).innerText & " " & p.Cells(1).innerText
End Sub