我正在尝试从网站导入播放器快照计数,但我的代码在按标签名称(“tr”)的 get 元素处产生错误,我不知道为什么。我已经使用代码从另一个站点导入 Web 数据,我不明白为什么会出错。我尝试访问的 URL 是:https://www.footballoutsiders.com/stats/nfl/snap-counts?year=2020&team=ALL&week=1&position=ALL
代码在 'For Each tr' 语句处停止工作。
建议,想法,答案?
Set hTable = html.querySelector("new-table modal-second-col responsive-enabled")
Dim td As Object, tr As Object, r As Long, c As Long
r = 1
With ws
.Cells(1, 1).Resize(1, UBound(headers) + 1) = headers
For Each tr In hTable.getElementsByTagName("tr")
r = r + 1: c = 1
If r > 3 Then
For Each td In tr.getElementsByTagName("td")
.Cells(r - 2, c) = IIf(c = 2, "'" & td.innerText, td.innerText)
c = c + 1
Next
End If
Next
End With
End Sub
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(21条)