嗨請檢查下面的代碼,希望可以幫助:
Function GetRSSResults() As String
GetRSSResults = GetHTTPResponse("https://water.weather.gov/ahps2/rss/fcst/fdyo1.rss")
r = GetRSSResults
s1 = Replace(r, ">", ">")
s2 = Replace(s1, "<", "<")
searchTerm = "Highest Projected Forecast Available: "
s = InStr(s2, searchTerm) + Len(searchTerm)
l = InStr(s, s2, "ft")
Debug.Print Trim(Mid(s2, s, l - s))
End Function
'------------------------------------------
Function GetHTTPResponse(url As String) As String
Dim msXML As Object
Set msXML = CreateObject("Microsoft.XMLHTTP")
With msXML
.Open "Get", url, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"
.send
GetHTTPResponse = .responseText
End With
Set msXML = Nothing
End Function
感謝您的答覆。我跑你的腳本,但它返回2空行。運行時不會出現任何錯誤或任何錯誤。有任何想法嗎?謝謝! – hunter21188
輸出將顯示在立即窗口中,我得到以下結果: <?xml version =「1.0」encoding =「UTF-8」?>
啊,好的。我試着從我的一個Subs中調用'Debug.Print s2'。我想我不能那樣做?我確實得到了完整的源代碼,這非常棒。但我想要的是隻檢索原來帖子中提到的那個號碼。那有意義嗎?謝謝! – hunter21188