Discussion Locked

Help with vb / getting info from HTML

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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.

3 replies

by bschaettle

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

by bschaettle

OK, here's a solution using an Active Server Page that scrapes the temperature from Weather Underground:
-------------------------------------------
<%
Function CurrentTemperature(iZipCode)
Dim sHTML
Dim beginpos
Dim endpos
Dim srvXmlHttp
Dim URL
CurrentTemperature = "(not available)" ' default
Set srvXmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
URL= "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=" & iZipCode
srvXmlHttp.open "GET", URL, false
srvXmlHttp.send()
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,"

")
' throw away everything before this
sHTML = Mid(sHTML,beginpos,len(sHTML))
' find the degree symbol that follows the temperature
endpos = Instr(sHTML,"°")
' throw away everything after the symbol
sHTML = Mid(sHTML,1,endpos)
' with what's left, find the tag just ahead of the temp
beginpos = Instr(sHTML,"")
sHTML = Mid(sHTML,beginpos+3,len(sHTML))
' with what's left, find the
tag just after the temp
endpos = Instr(sHTML,"
")
' 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
%>

Currently in Houston....
<% =CurrentTemperature(77001) %>

This discussion is closed to new replies.