我正在嘗試使用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