Weather app and website information gatherer
Hello everyone!!
It's been a long, long time since I've been coding. But today I had a fun idea for a weather app but I need some help..
I forgot the coding on how to get information from a website and put it to a text box in vb.net (2010).
I'm very bad at the advanced coding but I know how to make the application fun and wondering if any of you could help me out a little! I heard http://api.accuweather.com/ has a simplistic weather page.
You don't need to give me ALL the coding of course, just one to help me get the general idea
If someone could give me some sample coding on lets just say the temperature, that would be great. I want the user to but their zipcode into a textbox, click enter a text box will put the temp. another textbox.
Any help guys? It would be very very helpful.:):)
Re: Weather app and website information gatherer
Hi,
that API is subscriber only so unless someone here is subscribed to it we will not be able to help much.
Grabbing data from a webpage can be done many ways, for example, you can read the source into a string and then search the string for what you need.
If you let me know where you will get your data i can help more (if it is api.accuweather then some code or source would be needed).
Re: Weather app and website information gatherer
If you live in the US NOAA has an XML version of the weather. If you click on these two links
http://forecast.weather.gov/MapClick...0#.U0u4BFe2Wno
http://forecast.weather.gov/MapClick...&FcstType=dwml
You will see the relationship between the formatted and XML versions of the weather forecast.
Re: Weather app and website information gatherer
Quote:
Originally Posted by
bensonsearch
Hi,
that API is subscriber only so unless someone here is subscribed to it we will not be able to help much.
Grabbing data from a webpage can be done many ways, for example, you can read the source into a string and then search the string for what you need.
If you let me know where you will get your data i can help more (if it is api.accuweather then some code or source would be needed).
I private messaged you!:)
Re: Weather app and website information gatherer
Quote:
Originally Posted by
jj103
I private messaged you!:)
Please try and keep anything related to this thread public incase someone else who finds the thread looking for help can get it.
As per your message you still haven't said which one you will go with or which points of data you are after.
I will say that there is 2 ways I personally would go about this, the first is to download the source code as a string and then "search" the string for your info
Code:
Dim wc as New Webclient
Dim mytext as String
mytext = wc.DownloadString("http://www.myweather.com")
'search mytext for what you wish
The other way is very much the same but instead of searching for strings you assign the elements to a document and work with them
Code:
Dim wc as New Webclient
Dim mytext as String
mytext= wc.DownloadString("http://www.mysite")
Dim wb as New Webbrowser
wb.DocumentText = ""
wb.Document.OpenNew(false)
wb.Document.Write(mytext)
'you need to look at the source to see where to go now, if we had an element with an ID of say 'temp' then
Label1.Text = wb.Document.getElementById("temp").innerHTML
Re: Weather app and website information gatherer
Okay! Thank you very much, but I seem to not be able to find the "string"
Sorry..very long time and I can't figure it out.
Currently using "http://weather.yahooapis.com/forecastrss?w=2459115"
How would I find the string or "element ID" for lets just the temperature.
Again, thank you very much with the help.
(Using the second code provided by you)
Re: Weather app and website information gatherer
You are dealing with an XML document in that case use the below
Code:
Dim wc As New WebClient
Dim mytext As String
mytext = wc.DownloadString("http://weather.yahooapis.com/forecastrss?w=2459115")
Dim mt As New Xml.XmlDocument
mt.LoadXml(mytext)
Dim rr As Xml.XmlNodeList = mt.GetElementsByTagName("ttl")
For Each ee As Xml.XmlElement In rr
MsgBox(ee.InnerText)
Next
Re: Weather app and website information gatherer
Alright! So far looking good but I think one more question!
Temperature is found in the "ttl"
But for the others, let's say the extended forecast, it has a lot of data per tag.
Let's say I want a label to display Monday's high, and another label to display monday's low.
I think that's the last thing I need to learn, to be able to separate different bits of data in one tag.
Thank you!!
Re: Weather app and website information gatherer
instead of ee.innerText look at its other properties, you will find an answer