使用下面的腳本,我成功地返回從HTML表中的值到從下面的鏈接工作簿:link1和link2。但是,當我試圖對以下link3使用相同的腳本時,它不會返回任何內容。我認爲這是由於網站上存在複雜的HTML表格結構。我相信代碼需要.Item(0)號碼由於表格的複雜性而需要調整,請指教。刮HTML表格使用VBA
Sub Web_Data()
Dim http As New XMLHTTP60, html As New HTMLDocument
Dim topic As HTMLHtmlElement
With http
.Open "GET", "http://www.dolphinfitness.co.uk/en/optimum-nutrition/", False
.send
html.body.innerHTML = .responseText
End With
For Each topic In html.getElementsByClassName("category-products")
With topic.getElementsByClassName("product-name")
If .Length Then x = x + 1: Cells(x, 1) = .Item(0).innerText
End With
With topic.getElementsByClassName("price")
If .Length Then Cells(x, 2) = .Item(0).innerText
End With
Next topic
End Sub
可否請你彌補劇本,我會下載硒。 – Martin
我需要安裝哪個版本才能完成這項工作? [selenium下載頁面](http://www.seleniumhq.org/download/) – Martin
順便說一句,我看到我的評論看到你的腳本中的鏈接。這是你需要刮的鏈接嗎? – SIM