retrieving information from an web site

0 pts.
Tags:
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
ASKED: January 23, 2006  2:37 PM
UPDATED: January 27, 2006  8:21 AM

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

Cheers,

Ben

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • 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 = "web.site.address.here" 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:
    report
  • 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; http://www.ozexe.com )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","http://wwwa.accuweather.com/index-forecast.asp?partner=accuweather&myadc=0&zipcode=01507&u=1") 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:
    report
  • Palmcmc
    Thank you for all of your input I will try your suggestions and see what happens
    0 pointsBadges:
    report

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following