there is something strange i cant understand
when i click manually on command1 to get page source code on data arrival, i get all info to textbox without problem
but when i do it automatically, like get data on keyword found then i get truncated data into textbox
If InStr(strResponse, "login") Then
call command1_click
end if
i have this code on data arrival and it should automatically make a get request but it can only get truncated data
help please
No one can help without showing the *full* code that is not behaving ok according to you. FYI, Winsock control is working fine here and probably there is no problem at your site too.
So most probably the error is either within your code (cannot tell without seeing it) or within your understanding of how http over TCP/IP actually works (very probable considering the OP and the follow up post).
Is it a multiline-textbox (incl. expanded on the form to be bigger and show more lines than the "standard" one line?
Maybe there is a vbCrLF/chr(0) hidden in your data arriving......
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
Is it a multiline-textbox (incl. expanded on the form to be bigger and show more lines than the "standard" one line?
Maybe there is a vbCrLF/chr(0) hidden in your data arriving......
textbox is richtextbox multiline and there is no vbCrLF/chr(0)
i am using this right now, but still not working properly
If InStr(strResponse, "login") & Winsock1.BytesReceived Then
call command1_click
end if
it basically wait for winsock to finish to make another request but i am not sure why it not work well
it basically wait for winsock to finish to make another request but i am not sure why it not work well
Cannot tell without taking a look at the code. In ConnectionRequest you have to load a new instance of the Winsock control and call its Accept method with current requestID. It's this new instance which will receive data on the new client connection in the DataArrival event, not the original Winsock control that is Listen-ing for incomming connections.
Cannot tell without taking a look at the code. In ConnectionRequest you have to load a new instance of the Winsock control and call its Accept method with current requestID. It's this new instance which will receive data on the new client connection in the DataArrival event, not the original Winsock control that is Listen-ing for incomming connections.
cheers,
</wqw>
oh i didnt know about Accept method with current requestID
but i dont want to close winsock on new request, i want to keep winsock connected
so after spending the whole day working on this, i found the problem but dont know how to fix
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strResponse As String
Winsock1.GetData strResponse, vbString
RichTextBox1.Text = RichTextBox1.Text & strResponse Msgbox "Done" = right here this msgbox would show twice and this is the problem, i saw strResponse pasted into RichTextBox1.text twice on 2 parts
i need whole to strResponse once in full, not on 2 parts
please help
i only need to get page html source code with winsock
anyone can give me code to do it please
thanx
does it have to be winsock? will this work for you?
Code:
Public Function WebRequest(url As String) As String
Dim http As Object
Set http = CreateObject("MSXML2.ServerXMLHTTP")
http.Open "GET", url, False
http.Send
WebRequest = http.responseText
Set http = Nothing
End Function
The server can send 3 batches. The server can send multiple batches. There is no guarantee how many and in what intervals. You already do RichTextBox1.Text = RichTextBox1.Text & strResponse so there is no problem with chunking.
The problem is to figure out when you have the whole response. You have to parse "Content-Length" header and sum the size of all batches received. This is what XMLHTTP and WinHttpRequest are going to save you from implementing incorrectly.
The server can send 3 batches. The server can send multiple batches. There is no guarantee how many and in what intervals. You already do RichTextBox1.Text = RichTextBox1.Text & strResponse so there is no problem with chunking.
The problem is to figure out when you have the whole response. You have to parse "Content-Length" header and sum the size of all batches received. This is what XMLHTTP and WinHttpRequest are going to save you from implementing incorrectly.
cheers,
</wqw>
i already thought about "Content-Length" but it is not fixed, because page has data that changes each time
please help, i have spent the whole day looking everywhere and tried everything..
wait. I will upload a demo. but I need a URL to test
It is difficult to connect to https using winsock.
so i used serverhttp or winhttp . you can test
interesting control, but how can i make post request to login page? something like this:
Inet1.Execute "http://admin.5socks.net", "POST", "login=user&password=pass", "Content-Type: application/x-www-form-urlencoded"
SendData(URE As String, [SenaWe thod As ENn SENDMETHOD], [PostData], [Heads As String], [RefUrI As String], [Cookire As String], [FIags As
5tring=“标记“]) As Boolean
Last edited by xxdoc123; Oct 1st, 2020 at 02:09 AM.
SendData(URE As String, [SenaWe thod As ENn SENDMETHOD], [PostData], [Heads As String], [RefUrI As String], [Cookire As String], [FIags As
5tring=“标记“]) As Boolean
amazing control it worked, i just need one last thing that is to get cookies and make a post request using cookies
thats all i need please help
the control has some characters that my pc cant read, could you please upload only the control again ?
look at this for example:
here photo: https://prnt.sc/ur400f
Private Sub Timer1_Timer()
Dim tempCookie As String, tempSetCookie As String
If priStatus = EN_STOP Then Exit Sub 'Èç¹ûµ±Ç°ÊÇֹͣ״̬ÔòÍ˳ö
If priStatus <> EN_STOP Then
CurrentImage = (CurrentImage + 1) Mod Image1.Count
Image1(CurrentImage).ZOrder vbBringToFront
End If
On Error GoTo SilenceErr
Select Case NET.readyState 'ÅжÏ״̬
Case 4 '·¢ËÍÍê³É
If NET.Status = 200 Then 'NET.Status = 200 Or NET.Status = 206 Or NET.Status = 400 Or NET.Status = 302 Then 'httpÏìÓ¦´úÂëΪ200¡¡ÇëÇóok
priStatus = EN_STOP
priHeaders = NET.getAllResponseHeaders
priCookies = ´¦ÀíCookie(priHeaders)
m_BytReturn_Responsebodys = NET.responseBody
Abort
RaiseEvent SendComplete(m_StrFlags) 'Çý¶¯Ê¼þ
Exit Sub
Else priErrInfo = "·þÎñÆ÷ÏìÓ¦´úÂë:" & NET.Status