retrieving information from an web site

Visual Basic
I am trying to figure out how to search through HTML and retrieve certain information. such as loading the noaa weather Web site and and searching through the code and returning just the current temperature. I have seen this done using Java Script and even have the code to do it in java, but I need to do this in Visual Basic 6.0

Answer Wiki

Thanks. We'll let you know when a new response is added.

You probably won’t get much of a response on this site. It is related to SQL Server questions…

Try a site related to HTML, Java or VB



Discuss This Question: 3  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Stanton
    Here is an example of code. You will have to put in your own HTML tags as it won't let me put them in here. Public Function GetStuff() As Double On Error GoTo ErrorHandler Dim xmlDoc As New DOMDocument Dim RequestLevel As IXMLDOMElement Dim AddressLevel As IXMLDOMElement Dim AddressElementLevel As IXMLDOMElement Dim t As Variant Dim i As Integer Dim hOpen As Long, hConnection As Long, hFile As Long, numread As Long Dim sHeader As String, htmlfile As String, tmp As String * 2048 Dim bDoLoop As Boolean Dim WinHttpReq As WinHttp.WinHttpRequest Dim MYSERVERNAME As String Dim XmlString As String Dim strTemp As String Dim strResponse As String Dim strStatus As String Dim intLen As Integer MYSERVERNAME = "" Set WinHttpReq = New WinHttpRequest 'Here our proxy server is defined. WinHttpReq.SetProxy 2, "YOUR.PROXY.SERVER.COM" XmlString = MYSERVERNAME WinHttpReq.Open "GET", XmlString, False WinHttpReq.Send strResponse = Mid(WinHttpReq.ResponseText, InStr(WinHttpReq.ResponseText, "sometext"), 300) strStatus = WinHttpReq.Status & " - " & WinHttpReq.StatusText '***** Handle error If InStr(strResponse, "Error") > 0 Then intLen = InStr(strResponse, "endDescriptionTag") - InStr(strResponse, "DescriptionTag") - 13 strTemp = Mid(strResponse, InStr(strResponse, "DescriptionTag") + 13, intLen) MsgBox "There is an error of some type in the Address given." & vbCrLf & _ strTemp & vbCrLf & "Please correct and try again!", vbOKOnly Exit Function End If '**** Get specific Item You are looking for based on HTML tags and text within the HTML document If InStr(strResponse, "text") > 0 Then '**offset is the number of characters after the "text" I want to start at strResponse = Mid(strResponse, InStr(strResponse, "text") + offset, 100) strResponse = Mid(strResponse, 1, InStr(strResponse, "endtag") - 1) GetExchangeRate = Val(Trim(strResponse)) End If Exit Function ErrorHandler: MsgBox "Error # " & Err.Number & " has occurred!" & vbCr & _ Err.Description, vbOKOnly + vbExclamation, "ERROR GetStuff" Resume Next End Function Have fun. Stanton
    0 pointsBadges:
  • Wizard90
    I do this all the time. The problem with the noaa site is that the temperature is not in a "tag" persay, it is just text on the page. Not only that, the user can rearrange the page making finding the text within the page difficult. I use OZEXE (free to try; )as my tool of choice for this type of work. The following 5 lines of code will get the current temp from accuweather and display it: DevOpen( IE ) DevWrite(IE,"URL","") cTemp = DevRead( IE, "text", "Temperature:", 10, 1 ) MsgBox( cTemp, "Current Temperature" ) DevClose( IE ) If you were to uncheck the "Display browser on open" checkbox in the device interface setup, you could do this behind the scenes. The device interface for IE is very useful. Not only can you get text from a page, but you can read and write elements, hidden or visible, directly as well as run script and perform all navigation functions. Any time I need to get any data from anything or anywhere, I highly reccomend this tool.
    0 pointsBadges:
  • Palmcmc
    Thank you for all of your input I will try your suggestions and see what happens
    0 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: