Hello guys,
I have some problems with winsock. I have sample html code located on the server:
Let's say the file is called: test.phpCode:<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>
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:
For the data arrival I tried to use this code: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
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??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
Thanks in advance & much apreciated all your support!




Reply With Quote