我正在尝试下载网页的表格数据,但看起来该网页太大。
如果将“ .response”数据放入“字符串”变量中,然后将其保存到文本文件中,则将获取网页上的所有数据。如果将其保存到“ HTMLDocument”变量后执行此操作,则只会得到前51594个字符
这是我的脚本:
Sub nemigaparts_articles()
Dim oHtml As HTMLDocument
Dim oElement As Object
Dim URL As String
Dim id As String
Dim z As Long
Dim y As Long
Dim row As Long
Dim totaal As Long
Dim begin As Long
'data for save as
Dim start As Long
Dim eind As Long
Application.ScreenUpdating = False
begin = 1
totaal = 2
row = 1
start = 1
eind = 0
'laat statusbalk zien
UserForm1.Show
For z = begin To totaal Step 1
'get page data
'URL = Sheets("drawings").Cells(z, 3).Value
'id = Sheets("drawings").Cells(z, 1).Value
URL = "https://nemigaparts.com/cat_spares/pet/porsche/964/13/902000/"
id = 1
Set oHtml = New HTMLDocument
With CreateObject("WINHTTP.WinHTTPRequest.5.1")
.Open "GET", LCase(URL), False
.send
oHtml.body.innerHTML = .responseText
End With
Sheets("articles").Cells(1, 11) = z
Dim imageurl As Object
Set imageurl = oHtml.getElementsByClassName("col-lg-9 col-md-9 col-sm-9 col-xs-12 xs-margin-bottom-50")(0)
URL_img = imageurl.getElementsByTagName("a")(0).href
Dim atribuut As Object
Set atribuut = oHtml.getElementsByClassName("technical")(0)
If Not atribuut Is Nothing Then
x = oHtml.getElementsByTagName("tr").Length - 1
MsgBox (x)
For y = 1 To x Step 1
Sheets("articles").Cells(row, 1) = id
Sheets("articles").Cells(row, 2) = URL_img
Sheets("articles").Cells(row, 3) = oHtml.getElementsByTagName("tr")(y).innerHTML
row = row + 1
Next
End If
DoEvents
UserForm1.Label2.Width = (z / totaal * 100) / 100 * 186
UserForm1.Label4.Caption = "Artikel " & z & " van " & totaal
Next
End Sub