General discussion


Help with vb / getting info from HTML

By palmc ·
I need to be able to pull information from an html web site and pull that information into a Visual Basic App.

Such as pulling the Temperature off of the Noaa web site ??? any help Appreciated.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by palmc In reply to Help with vb / getting in ...

Point value changed by question poster.

Collapse -

by bschaettle In reply to Help with vb / getting in ...

You want to post the local temperature on your intranet?
You need to do a Google search on "screen scraping". Also look for "MSXML".

Collapse -

by bschaettle In reply to Help with vb / getting in ...

OK, here's a solution using an Active Server Page that scrapes the temperature from Weather Underground:
Function CurrentTemperature(iZipCode)
Dim beginpos
Dim endpos
Dim srvXmlHttp
CurrentTemperature = "(not available)" ' default
Set srvXmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
URL= "" & iZipCode "GET", URL, false
If srvXmlHttp.status = 200 Then
' grab the HTML source for the entire page
sHTML = srvXmlHttp.responseText
' find a tag that occurs just before the current temperature
beginpos = Instr(sHTML,"<td class=""full"" id=""message2"">")
' throw away everything before this
sHTML = Mid(sHTML,beginpos,len(sHTML))
' find the degree symbol that follows the temperature
endpos = Instr(sHTML,"&#176")
' throw away everything after the symbol
sHTML = Mid(sHTML,1,endpos)
' with what's left, find the <b> tag just ahead of the temp
beginpos = Instr(sHTML,"<b>")
sHTML = Mid(sHTML,beginpos+3,len(sHTML))
' with what's left, find the </b> tag just after the temp
endpos = Instr(sHTML,"</b>")
' grab the temp from between the tags and add a degree symbol
CurrentTemperature = Mid(sHTML,1,endpos-1) & "°"
End If
Set srvXMLHttp = Nothing
End Function ' CurrentTemperature
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<i>Currently in Houston....</i>
<% =CurrentTemperature(77001) %>

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums