VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get html Source of any web site

by liaqat fayyaz (10 Submissions)
Category: Internet/HTML
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 8th May 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Get html Source of any web site

API Declarations



Dim sURL As String
Dim sHost As String
Dim sPage As String
Dim lPort As Long


Rate Get html Source of any web site




Private Sub GetHTMLSource(ByVal sURL As String)
  txtSource = ""
  sHost = Mid(sURL, InStr(sURL, "://") + 3)
  If InStr(sHost, "/") > 0 Then
    sPage = Mid(sHost, InStr(sHost, "/"))
    sHost = Left(sHost, InStr(sHost, "/") - 1)
  Else
    sPage = "/"
  End If
  If InStr(sHost, ":") > 0 Then
    lPort = Mid(sHost, InStr(sHost, ":") + 1)
    sHost = Left(sHost, InStr(sHost, ":") - 1)
  Else
    lPort = 80
  End If
  With Winsock1
    If .State <> sckClosed Then .Close
    .RemoteHost = sHost
    .RemotePort = lPort
    .Connect
  End With
End Sub

Private Sub cmdGet_Click()
  GetHTMLSource txtURL
End Sub

Private Sub Form_Load()

End Sub

Private Sub Timer1_Timer()
  Winsock1.Close
  txtSource = "Connection timeout"
End Sub

Private Sub Winsock1_Connect()
  Timer1.Enabled = True
  Winsock1.SendData "GET " & sPage & " HTTP/1.0" & Chr(10) & Chr(10)
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
  Timer1.Enabled = False
  Dim sBuffer As String
  Winsock1.GetData sBuffer
  txtSource = txtSource & sBuffer
End Sub

Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
  Winsock1.Close
  txtSource = "Error " & Number & ": " & Description
End Sub


Download this snippet    Add to My Saved Code

Get html Source of any web site Comments

No comments have been posted about Get html Source of any web site. Why not be the first to post a comment about Get html Source of any web site.

Post your comment

Subject:
Message:
0/1000 characters