I WAS looking forward to the idea of RSS and having a weather feed on a Form but I'm 7 years too late? I know WeatherUnderGround for a feed is dead. Can't find much help with Weather.com either and all the other sites that seem to be part of Weather.Com. Are there any other sites that have Free RSS feeds or better way to do this that again is um "freeish"?
Google gave me sites that no longer have. And ChatGPT um well laughed at me and said its 2024 not 2010.
Jeffrey KraftOP
@Reply 2 years ago
That L part was Lesson 2 and the word AND is missing 3. I left that in my post because well.....
Adam Schwanz
@Reply 2 years ago
I have some code laying around somewhere for a weather API that puts the weather report into access. You have to manipulate the data to show what you want, i think the code i have just says the forecasted weather for the current day. Youll also have to lookup your own weather tower coordinates near you, but ill look for my code and share it if youd want it.
Jeffrey KraftOP
@Reply 2 years ago
Please. I don't need 5 days. I saw some API stuff and well for a bit it was above my head. But I'm sure I'd eventually pick it up. M A Y B E.
I just tried and it said invalid API key, and their docs say that it can take a "couple of hours" for API keys to become valid. So I'll try again in the morning. If it works, we have a new source, and I'll make a video about all of this. :)
If / when it does work, then you just have to parse the JSON that's returned, which is pretty easy if you're only looking for one specific thing. Just use my FindBetween function.
I should always search my own website before digging into stuff like this. 17 months ago, Scottposted a link to 7 good RSS feeds that you can use that work the same way as the XML import method I show in class. So, Jeffrey, you don't need all this VBA API stuff I posted above. You can use this method until you get up to the VBA level.
I'm still gonna make a video out of it though. LOL.
Adam Schwanz
@Reply 2 years ago
Here's the code I use. The response is massive and you can get so much info from it though so you need to parse the response.
It's from weather.gov, and on their website you can lookup towers in your area to get the data from. I think last time I shared this code it was for FL, so thats the coordinates in it right now. But Richard's API may be easier. This returns a response like this "Weather Forecast: A chance of rain showers. Cloudy, with a low around 69. South wind around 6 mph. Chance of precipitation is 40%. New rainfall amounts less than a tenth of an inch possible."
CODE Private Sub GetWeather()
'API connection from weather.gov
On Error GoTo ErrHandle
Dim MyURL
Dim objrequest
Dim MyResponse As String
Set objrequest = CreateObject("WinHTTP.WinHTTPRequest.5.1")
MyURL = "https://api.weather.gov/gridpoints/OKX/52,39/forecast"
With objrequest
.Open "GET", MyURL, False
.Send
MyResponse = .ResponseText
End With
'Remove Extra Spacing
Do While InStr(MyResponse, " ")
MyResponse = Replace(MyResponse, " ", " ")
Loop
'Cut Response to Current Section
MyResponse = Mid(MyResponse, InStr(MyResponse, "periods"": [ { ""number"": 1"))
MyResponse = Left(MyResponse, InStr(MyResponse, "{ ""number"": 2"))
'Cut Response to detailedForecast
MyResponse = Mid(MyResponse, InStr(MyResponse, "detailedForecast"))
'Remove Leading/Ending Text
MyResponse = Replace(MyResponse, "detailedForecast"": """, "")
MyResponse = Replace(MyResponse, """ }, {", "")
Weather = "Weather Forecast: " & MyResponse
'Exit sub before ErrHandle
Exit Sub
ErrHandle:
'If you get an error after going from design view to form view on the main menu. Ignore this error. It's working as it should in normal use.
Weather = "There was an error with the weather API, try again later"
End Sub
Private Sub Form_Current()
GetWeather
End Sub
Private Sub Form_Timer()
GetWeather
End Sub
Jeffrey KraftOP
@Reply 2 years ago
Cool. Thank you as well as Lord Dancing with Penguins Richard ... I just watched the video he gave the link to and its not hard. I then stared at the code somebody else gave me regarding weather. Fainted. Recovered and now I look at yours I kind of get it.
Richard. I've been using VBA for a long while. Like you I don't really like Macros. Prefer VBA over everything else. I went to the 7 Good RSS Feeds post as well. Did Yahoo got nowhere. Accuweather - either did it wrong or I don't know - works for me now. RssWeather has a host issue.... so long story short... yes I do need all the VBA stuff because I prefer VBA.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Expert 24.