Results 1 to 12 of 12

Thread: [RESOLVED] Winsock Data arrival problem

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    24

    Resolved [RESOLVED] Winsock Data arrival problem

    Hello guys,

    I have some problems with winsock. I have sample html code located on the server:

    Code:
    <table border="1" bordercolor="#FFCC00" style="background-color:#FFFFCC" width="100%" cellpadding="3" cellspacing="3">
    	<tr>
    		<td class="niki">Nickname</td>
    		<td>019284724</td>
    	</tr>
    	<tr>
    		<td>George</td>
    		<td>259825983</td>
    	</tr>
    	<tr>
    		<td>James</td>
    		<td>291953533</td>
    	</tr>
    </table>
    Let's say the file is called: test.php

    I want to catch data located betweem <td> and </td> tags and locate them under Listview control (using subitem system)

    I created a winsock connect and data arrival code for that:

    Code:
    Private Sub Winsock3_Connect()
        Winsock3.SendData ("GET /test.php" & " HTTP/1.1" & vbCrLf & _
             "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, */*" & vbCrLf & _
            "Accept-Language: en-us" & vbCrLf & _
            "Content-Type: application/x-www-form-urlencoded" & vbCrLf & _
            "Accept-Encoding: gzip, deflate" & vbCrLf & _
            "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90)" & vbCrLf & _
            "Host: " & "site.com" & ":80" & vbCrLf & vbCrLf)
    End Sub
    For the data arrival I tried to use this code:

    Code:
    Private Sub Winsock3_DataArrival(ByVal bytesTotal As Long)
     Dim Data As String
        Dim tempstr As String
        Dim beg As Long
        Dim tmfin As Long
        Winsock3.GetData Data
        Data2 = Data2 & Data
        beg = InStr(Data2, "<td>") + 4
      tmfin = InStr(beg, Data2, "</td>") - beg
      tempstr = Mid(Data2, beg, tmfin)
      RichTextBox1.Text = tempstr
      
    End Sub
    I solved the run time error 5 issue. I have another question now: there are different elements between <td> and </td> but I only get the first one. How to load them all??

    Thanks in advance & much apreciated all your support!
    Last edited by david_707; Jan 24th, 2013 at 10:24 AM.

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