【发布时间】:2019-12-13 11:30:37
【问题描述】:
我有一个关于 HTML 解析的问题。我想将this site 中的文本捕获到我当前的电子表格中,但代码只能循环遍历每一页。
Sub Data()
Dim Http As New XMLHTTP60, Html As New HTMLDocument, topic As HTMLHtmlElement
With Http
.Open "GET", "https://voronezh.leroymerlin.ru/catalogue/dekorativnye-oboi/?sortby=1&display=90", False
.send
Html.body.innerHTML = .responseText
End With
For Each topic In Html.getElementsByClassName("ui-product-card__info")
With topic.getElementsByClassName("product-name")
If .Length Then x = x + 1: Cells(x, 1) = .item(0).innerText
End With
With topic.getElementsByClassName("main-value-part")
If .Length Then Cells(x, 2) = .item(0).innerText
End With
Next topic
End Sub
如何在流程中循环下一页以捕获所有数据?
【问题讨论】:
标签: excel vba web-scraping html-parsing