its quite easy to connect to the internet and fetch pages you can use that code below
Imports System.Net
Imports System.IO
Public Class AWebFetcher
Private _nodename As String
Public Event DataReceived(ByVal node As String, ByVal _data As String)
Public Event ErrorReceived(ByVal node As String, ByVal _errmsg As String)
Public Sub New(ByVal node As String)
_nodename = node
End Sub
Public Sub Fetch(ByVal _url As String)
'First, you need to convert URL of the webpage from text format, to "System.Uri".
Dim requestUri As New Uri(_url)
'Then, we will create the "WebClient".
Dim wc As New WebClient
'Followed by adding the "link" to the "I_Receive_Data" Event Handler (when download finishes, it gets the webpage source)
AddHandler wc.DownloadStringCompleted, AddressOf I_Receive_Data
'Trap for possible network errors
Try
wc.DownloadStringAsync(requestUri)
Catch ex As WebException
RaiseEvent ErrorReceived(_nodename, ex.Message)
End Try
End Sub
Private Sub I_Receive_Data(ByVal sender As Object, ByVal e As System.Net.DownloadStringCompletedEventArgs)
'Remember, the "DownloadStringCompleted" event fires even if error happened in download process
If Not e.Error Is Nothing Then Exit Sub
'We checked it by the e.Error argument
'e.Result contains requested webpage as a string
RaiseEvent DataReceived(_nodename, e.Result)
End Sub
End Class
!--removed tag-->
Enter your message below
Sign in or Join us (it's free).