Her er en funktion som måske kan hjælpe
Public Function OpenURL(ByVal sInURL As String) As String
Dim iP As Integer
Dim sURL As String
Dim sURLHost As String
Dim sURLPath As String
Dim abyteReceive(1024) As Byte
'The path parsing should be more robust ...
iP = InStr(UCase$(sInURL), "
HTTP://")
If iP > 0 Then
sURL = Mid$(sInURL, iP + 7)
Else
sURL = sInURL
End If
iP = InStr(sURL, "/")
If iP > 0 Then
sURLHost = Mid(sURL, 1, iP - 1)
sURLPath = Mid(sURL, iP)
Else
sURLHost = sURL
sURLPath = "/"
End If
'should be supporting HTTP 1.1
Dim s As String = ""
Dim sGet As String = "GET " & sURLPath & " HTTP/1.0" & CrLf & " Host: " & sURLHost & CrLf & "Connection: Close" & CrLf & CrLf
Dim asciiGet As Encoding = Encoding.ASCII
Dim abyteGet() As Byte = asciiGet.GetBytes(sGet)
Try
Dim hostentry As IPHostEntry = Dns.GetHostByName(sURLHost)
Dim hostadd As IPAddress = hostentry.AddressList(0)
Dim EPhost As IPEndPoint = New IPEndPoint(hostadd, 80)
Dim sockHTTP As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
sockHTTP.Connect(EPhost)
If sockHTTP.Connected = False Then
OpenURL = "Unable to connect to host: " & sURLHost
Exit Function
End If
sockHTTP.Send(abyteGet, abyteGet.Length, 0)
Dim iBytes As Integer = sockHTTP.Receive(abyteReceive, abyteReceive.Length, 0)
s = "HTML from " & sURL & "(" & hostadd.ToString & "):" & CrLf
s &= asciiGet.GetString(abyteReceive, 0, iBytes)
Do While iBytes > 0
iBytes = sockHTTP.Receive(abyteReceive, abyteReceive.Length, 0)
s &= asciiGet.GetString(abyteReceive, 0, iBytes)
Loop
sockHTTP.Close()
sockHTTP = Nothing
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
OpenURL = s
End Function