我正在尝试使用VBA网页刮取从Met办公室网站为伦敦拉最低夜间温度。我试过使用代码here。虽然代码运行它不是复制我需要它复制。援助将不胜感激。使用vba从网站上刮取数据4
Sub WebScrape_1()
'Create an Internet Explorer browser
Dim appIE As Object
Set appIE = CreateObject("internetexplorer.application")
'Browse the browser to the target webpage
With appIE
.Navigate "https://www.metoffice.gov.uk/public/weather/forecast/gcpvj0v07"
.Visible = True ' False activate when happly with code
End With
'Wait while loading
Do While appIE.Busy
DoEvents
Loop
'What aspect of the webpage to copy
Set allRowOfData = appIE.document.getElementById("nightValue0")
Dim myValue As String: myValue = allRowOfData.innerHTML
'Close the browser
appIE.Quit
Set appIE = Nothing
'Paste the data into the selected range
ActiveWorkbook.Sheets("Data_Temp").Range("C7").Value = myValue
End Sub
'没有luck'没有描述任何种类的问题......我不认为有人在这里会浪费自己的时间猜测这是什么意思 – jsotola
同意@jsotola。你会得到一些结果吗?错误的结果?没有结果?错误消息?您需要提供有关运行代码时发生的情况的更多信息。 – freginold
稍微更新了该问题。不确定如何将我的代码复制到网页的相关部分。 – Karm