Weather board, how to get html data.

  • Thread starter Thread starter Boki
  • Start date Start date
B

Boki

Hi All,

I am going to create a personal weather board.

It is easy to show the picutre on website ( just link the picture to
picturesbox's properties )

but I dont' know how to add some other text near by..

for example:

I can get the weather icon, but I don't know how to get the description
text...

What should I do?

Best regards,
Boki.
 
Depends if you are talking about text adjacent to the picture or Alernate
text, iether way you will need to scrape the site and parse the text. Seach
for web scraping on google.
 
Hi All,

I am going to create a personal weather board.

It is easy to show the picutre on website ( just link the picture to
picturesbox's properties )

but I dont' know how to add some other text near by..

for example:

I can get the weather icon, but I don't know how to get the description
text...

What should I do?

Best regards,
Boki.

Don't know where you are, but if in the U.S. the NWS has several XML
feeds which make it very easy to use directly in a app. Here is a
current observation example:
http://www.weather.gov/data/current_obs/KSFO.xml

Gene
 
gene kelley 寫é“:
Don't know where you are, but if in the U.S. the NWS has several XML
feeds which make it very easy to use directly in a app. Here is a
current observation example:
http://www.weather.gov/data/current_obs/KSFO.xml

Gene

I use InStr() to search WebBrowser1.DocumentText, could you please
advice how to search the XML data tag? ( a better way than InStr() )..

Best regards,
Boki.
 
Boki,

To read an unknown xml document is this probably the easiest method

http://www.vb-tips.com/default.aspx?ID=e788c048-e547-4de3-9c6a-22589f018cd4

I hope this helps,

Cor

"Boki" <[email protected]> schreef in bericht

gene kelley ??:
Don't know where you are, but if in the U.S. the NWS has several XML
feeds which make it very easy to use directly in a app. Here is a
current observation example:
http://www.weather.gov/data/current_obs/KSFO.xml

Gene

I use InStr() to search WebBrowser1.DocumentText, could you please
advice how to search the XML data tag? ( a better way than InStr() )..

Best regards,
Boki.
 
Hi,

I have used the yahoo weather rss for this. They have a
weather sticker embedded in it. The address for the rss feed has a
querystring for getting the weather. In the us use your zipcode for getting
the weather. This example requires a textbox (txtZip) for entering in a
zipcode to get the weather for, webbrowser control to display the weather
sticker, and a button (btnGetWeather).

Private Sub btnGetWeather_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnGetWeather.Click
Dim sr As IO.StreamReader
Dim wc As New System.Net.WebClient
Dim strUrl As String
Dim strOut As String = ""
strUrl =
String.Format("http://xml.weather.yahoo.com/forecastrss?p={0}", txtZip.Text)

Try
sr = New IO.StreamReader(wc.OpenRead(strUrl))
Dim strHtml As String = sr.ReadToEnd
Dim x As Integer = strHtml.IndexOf("<img src")
Dim y As Integer = strHtml.IndexOf(")<br/>")
strOut = strHtml.Substring(x, y - x + 6)
sr.Close()
Catch
strOut = "<h1>Error getting weather</h1>"
Finally
WebBrowser1.DocumentText = strOut
End Try
End Sub

Ken
 
Boki said:
I am going to create a personal weather board.

It is easy to show the picutre on website ( just link the picture to
picturesbox's properties )

but I dont' know how to add some other text near by..

for example:

I can get the weather icon, but I don't know how to get the description
text...

Parsing an HTML file:

MSHTML Reference
<URL:http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/reference.asp>

- or -

..NET Html Agility Pack: How to use malformed HTML just like it was
well-formed XML...
<URL:http://blogs.msdn.com/smourier/archive/2003/06/04/8265.aspx>

Download:

<URL:http://www.codefluent.com/smourier/download/htmlagilitypack.zip>

- or -

SgmlReader 1.4
<URL:http://www.gotdotnet.com/Community/...mpleGuid=B90FDDCE-E60D-43F8-A5C4-C3BD760564BC>

If the file read is in XHTML format, you can use the classes contained in
the 'System.Xml' namespace for reading information from the file.
 
Ken Tucker said:
Hi,

I have used the yahoo weather rss for this. They have a
weather sticker embedded in it. The address for the rss feed has a
querystring for getting the weather. In the us use your zipcode for
getting the weather. This example requires a textbox (txtZip) for entering
in a zipcode to get the weather for, webbrowser control to display the
weather sticker, and a button (btnGetWeather).

Private Sub btnGetWeather_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnGetWeather.Click
Dim sr As IO.StreamReader
Dim wc As New System.Net.WebClient
Dim strUrl As String
Dim strOut As String = ""
strUrl =
String.Format("http://xml.weather.yahoo.com/forecastrss?p={0}",
txtZip.Text)

Try
sr = New IO.StreamReader(wc.OpenRead(strUrl))
Dim strHtml As String = sr.ReadToEnd
Dim x As Integer = strHtml.IndexOf("<img src")
Dim y As Integer = strHtml.IndexOf(")<br/>")
strOut = strHtml.Substring(x, y - x + 6)
sr.Close()
Catch
strOut = "<h1>Error getting weather</h1>"
Finally
WebBrowser1.DocumentText = strOut
End Try
End Sub

Ken


Neat Ken!!! And works well.
james

(not the original poster, but, someone who appreciates interesting code!)
 
gene kelley ???


I use InStr() to search WebBrowser1.DocumentText, could you please
advice how to search the XML data tag? ( a better way than InStr() )..

Best regards,
Boki.

As noted in other responses, you would want to read the XML elements
directly (XML Reader Class). Has nothing to do with a WebBrowser.

Gene
 
Back
Top