How to retrive HTML Content from a given URL with VB 2008

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cardei
    New Member
    • Feb 2008
    • 5

    How to retrive HTML Content from a given URL with VB 2008

    Hi, I try to retrieve html content from a web page with VB .net

    I used this code (console app) that I find on internet :

    Code:
     
    Imports System
    Imports System.Net
    Imports System.IO
    Module Module1
    
      Sub Main()
            Dim sURL As String
            sURL = "http://www.checkmytrip.com"
    
            Dim wrGETURL As WebRequest
            wrGETURL = WebRequest.Create(sURL)
    
            Dim myProxy As New WebProxy("myproxy", 80)
            myProxy.BypassProxyOnLocal = True
    
            'wrGETURL.Proxy = myProxy
            wrGETURL.Proxy = WebProxy.GetDefaultProxy()
    
            Dim objStream As Stream
            objStream = wrGETURL.GetResponse.GetResponseStream()
    
            Dim objReader As New StreamReader(objStream)
            Dim sLine As String = ""
            Dim i As Integer = 0
    
            Do While Not sLine Is Nothing
                i += 1
                sLine = objReader.ReadLine
                If Not sLine Is Nothing Then
                    Console.WriteLine("{0}:{1}", i, sLine)
                End If
            Loop
    
            Console.ReadLine()
    
        End Sub
    
    End Module
    It's work fine in console mode but when I paste it in my app the app is crash or stop responding.

    I replaplace the line 30,
    Code:
    Console.WriteLine("{0}:{1}", i, sLine)
    with
    Code:
    textbox1.text = textbox1.text & sline
    and I deleted the line 34.

    I need to extract some data from a given URL to use it later in my app.

    If somebody can help me??

    Sory for my english! :)

    Thanks.
Working...