-
Anyone have a snippit of code where they get winsock to behave as inet.getpage? I am just looking to download a web page and save it as a string.
Under Win2000, iNet.getpage seems to be flakey and my attepmt at learnign winsock is not coming a long too fast.
A specific example of using winsock to get the HTML source of a web page would be very helpful.
thanks
jfs
-
I'm not sure but I think it should be:
Code:
Private Sub GetHTML(ByVal sHost As String, ByVal sPage As String)
'Stop any concurrent operations
Winsock1.Close
'Connect to the specified host. Eg. 200.56.144.9 or http://www.website.com
Winsock1.Connect sHost, 80
'Request the data of the page, Eg. Index.html, default.asp, files/about.htm, ...
Winsock1.SendData "GET " & sPage
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData sHTML, vbString, bytesTotal
'sHTML conatins the HTML of the requested page.
End Sub
-
Correction:
I think you should move this line to the Connect event of the Winsock control:
Winsock1.SendData "GET " & sPage