我并入了一个代码,该代码可以从具有登录凭据的网站中提取信息到我的工作表中,并且某种程度上不起作用。
我的工作表在A列中有一系列子URL,这些子URL都在同一主URL下。
第.Open "POST", URL, False
行出现错误
Option Explicit
Sub onlinedata()
Dim Http As New XMLHTTP60, html As New HTMLDocument
Dim lastrow As Long, i As Long
Dim output As String
Dim URL As Range
Dim response As String
Dim username As String
Dim password As String
username = "x"
password = "y"
i = 2
For Each URL In Range(Cells(3, "A"), Cells(Rows.Count, "A").End(xlUp))
With Http
.Open "POST", URL, False, username, password
.send
html.body.innerHTML = .responseText
End With
output = html.getElementsByClassName("price priceGray")(0).innerText
i = i + 1
Cells(i, "B") = output
Next URL
End Sub
更新:5/21:
我已经尝试过一些代码,并将它们添加到我最初发布的代码中。现在,错误出现在output = html.getElementsByClassName("price priceGray")(0).innerText
中,并显示以下错误消息。
Run-time error '91':
Object variable or With block variable not set
我正试图从<div class="price priceGray">$93,350</div>
获得$ 93,350。我想我快到了,我只需要一点帮助。