【发布时间】:2021-05-13 19:50:05
【问题描述】:
希望一切都好!我检查了其他帖子,但我无法提取 MP3 URL(我可以在调试打印中看到它们)。我知道它们以“.href”结尾,但是我切片宏甚至不会完成..
请注意,我已启用 Microsoft XML v6.0 和 HTML 对象库
Sub FETCHER()
Dim xmlHttp As Object
Dim TR_col As Object, Tr As Object
Dim TD_col As Object, Td As Object
Dim row As Long, col As Long
Set xmlHttp = CreateObject("MSXML2.XMLHTTP.6.0")
myURL = "https://www.zophar.net/music/nintendo-64-usf/1080-Snowboarding"
xmlHttp.Open "GET", myURL, False
xmlHttp.setRequestHeader "Content-Type", "text/xml"
xmlHttp.send
Dim html As Object
Set html = CreateObject("htmlfile")
html.body.innerHTML = xmlHttp.responseText
Dim tbl As Object
Set tbl = html.getElementById("tracklist")
row = 1
col = 1
Set TR_col = html.getElementsByTagName("TR")
For Each Tr In TR_col
Set TD_col = Tr.getElementsByTagName("TD")
For Each Td In TD_col
Cells(row, col) = Td.innerText
'.href reference would go here-------
col = col + 1
Next
col = 1
row = row + 1
Next
End Sub
--
任何帮助将不胜感激。 感谢您的宝贵时间!
【问题讨论】:
标签: html excel vba web-scraping