【发布时间】:2018-06-13 19:33:14
【问题描述】:
尝试进行简单的 Web 解析,我的问题是页面在您向下滚动之前无法完全加载。谷歌搜索可能会使用 selenium,但由于我不知道如何使用它,所以我想我会在这里问
我正在使用的代码
Sub gfquote()
Dim oHttp As MSXML2.XMLHTTP
Dim sURL As String
Dim HTMLDoc As HTMLDocument
Dim dequote As String
Dim driver As New Webd
' Create an XMLHTTP object
Set oHttp = New MSXML2.XMLHTTP
Dim oElement As Object
' get the URL to open
sURL = "https://www.thevinylspectrum.com/siser-heat-transfer-vinyl/siser-easyweed/12in-x-59in-rolls/"
' open socket and get website html
oHttp.Open "GET", sURL, False
oHttp.send
Set HTMLDoc = New HTMLDocument
With HTMLDoc
' assign the returned text to a HTML document
.body.innerHTML = oHttp.responseText
dastring = oHttp.responseText
' parse the result
UserForm1.TextBox1.Text = dastring
Set prices = .getElementsByClassName("price product-price")
For Each oElement In prices
Sheets("Sheet1").Range("A" & i + 1) = prices(i).innerText
i = i + 1
Next oElement
End With
'Clean up
Set oHttp = Nothing
End Sub
【问题讨论】: