Results 1 to 2 of 2

Thread: Winsock Download HTML file

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Im trying to download a html file with
    winsock. im not sure of why but its not
    working.. could someone who knows alittle
    more than me give me some code.

    thanks


  2. #2
    Guest
    Try this:

    Code:
    'You must have a Winsock control loaded into the project. 
    'This code assumes the control is called Winsock1. 
    'There also must be a text box on the form which is called txtWebPage.
    
    'First, connect to the remote computer using the following code:
    
    Winsock1.RemoteHost = "visualbasic.about.com"
    Winsock1.RemotePort = 80
    Winsock1.Connect
    
    Dim strCommand as String
    Dim strWebPage as String
    strWebPage = _
    "http://visualbasic.about.com/compute/visualbasic/index.htm"
    strCommand = "GET " + strWebPage + " HTTP/1.0" + vbCrLf 
    strCommand = strCommand + "Accept: */*" + vbCrLf 
    strCommand = strCommand + "Accept: text/html" + vbCrLf 
    strCommand = strCommand + vbCrLf 
    Winsock1.SendData strCommand
    The Winsock control will attempt to download the page. When is receives some data from the server, it will trigger the DataArrival event.
    
    Dim webData As String 
    Winsock1.GetData webData, vbString
    TxtWebPage.Text = TxtWebPage.Text + webData

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width