i have this code but it can grab only a part of the page source code, how can i make it grab the whole page source code?
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData, vbString, bytesTotal
Text1.Text = strData
End Sub
DataArrival events can occur with as little as 1 byte of data received, and at most 8192 bytes of data. You have to accumulate data until "the end" (however your protocol defines that).
DataArrival events can occur with as little as 1 byte of data received, and at most 8192 bytes of data. You have to accumulate data until "the end" (however your protocol defines that).
To get all the data you have to get reading and storing the data until the data stream stops. It could take many reads to get it all. You have to buffer the data with each read.
The code you have will end up showing only the last read as you are overwriting the variable each time.
As a simple test try changing the line
Code:
Text1.Text = strData
to
Code:
Text1.Text = Text1.Text & strData
this should show you all the data even with multiple reads.
Now this is not the way to handle a read, you really need a buffer var of some sort but that simple change should show you the difference.
To get all the data you have to get reading and storing the data until the data stream stops. It could take many reads to get it all. You have to buffer the data with each read.
The code you have will end up showing only the last read as you are overwriting the variable each time.
As a simple test try changing the line
Code:
Text1.Text = strData
to
Code:
Text1.Text = Text1.Text & strData
this should show you all the data even with multiple reads.
Now this is not the way to handle a read, you really need a buffer var of some sort but that simple change should show you the difference.
i already tried that, it keep getting old text + new text, i cant do that
i need actual code to get whole page source with each time new data
If you use winsock to download web pages. You can detect that the returned data contains the file header, which contains the size of the returned data. The cumulative return knows that it is greater than the size in the file header.
If you use winsock to download web pages. You can detect that the returned data contains the file header, which contains the size of the returned data. The cumulative return knows that it is greater than the size in the file header.
please give me code to do it
i am browsing a site using winsock and i need to get full page source code to textbox on data arrival event
but i can only so far get a first page of page source only, i need to get it all
Asking for people to give you code is not going to get you the code most of the time. I would suggest searching this site and others for examples using WinSock and web pages.
Insomnia is just a byproduct of, "It can't be done"
Asking for people to give you code is not going to get you the code most of the time. I would suggest searching this site and others for examples using WinSock and web pages.
i searched everywhere and i could not find the code i need, in ready to hire someone here to do the task
You have to clear the text before you try to load a new page.
tried it, didnt work
the problem is that Winsock1.GetData has limit of data it can get
i need to somehow grab all data, i hope i can find someone who can give me code to do it
tried it, didnt work
the problem is that Winsock1.GetData has limit of data it can get
i need to somehow grab all data, i hope i can find someone who can give me code to do it
Wow, if you did it right it would work. No I am not going to write it for you. Using the code I showed before you simply to to have an empty text box when you start to load the data, the data will go through in as many chunks as needed and each will append to the text in the text box. Once all the data is loaded for that page and you want to load a different one then you need to clear the text box before you start to load the next page. Very simple.
Now if the page you are trying to load has a lot of data coming back it may be to much for a text box and you may need to use a different control than can hold more data.
In any case the method I showed you will work if you just stop and think about it rather than begging for code it would be working already.
tried it, didnt work
the problem is that Winsock1.GetData has limit of data it can get
i need to somehow grab all data, i hope i can find someone who can give me code to do it
flag = ""
WinSockHttp1.Post_data = Text4.Text
WinSockHttp1.Head_cookie = CoS
WinSockHttp1.Successflags = "flag xxxx" ’Set a flag to determine whether all required web pages have been downloaded. Sometimes we only need part of the webpage content
WinSockHttp1.SockHttp "http://XXX.COM,", mPOST, "1011101"
Private Sub WinSockHttp1_ReturnComplete( Arraydata() As Byte, Flags As String)
strWeb = WinSockHttp1.Return_webstring ‘download complete string
‘’Arraydata is bytearrays。
'Debug.Print index
'raw.debug_print strweb
End Sub
The code logic is not very clear. Modify it yourself, I suggest you use winhttp
Last edited by xxdoc123; Sep 16th, 2020 at 09:06 PM.
flag = ""
WinSockHttp1.Post_data = Text4.Text
WinSockHttp1.Head_cookie = CoS
WinSockHttp1.Successflags = "flag xxxx" ’Set a flag to determine whether all required web pages have been downloaded. Sometimes we only need part of the webpage content
WinSockHttp1.SockHttp "http://XXX.COM,", mPOST, "1011101"
Private Sub WinSockHttp1_ReturnComplete( Arraydata() As Byte, Flags As String)
strWeb = WinSockHttp1.Return_webstring ‘download complete string
‘’Arraydata is bytearrays。
'Debug.Print index
'raw.debug_print strweb
End Sub
The code logic is not very clear. Modify it yourself, I suggest you use winhttp
i am gettting error: Ambiguous name detected: BytesToBstr Attachment 178764