Rc.inet1. Execute the URL, "POST", _
The data, _
"The content-type: application/x - WWW - form - urlencoded"
The Do While rc.inet1. StillExecuting
DoEvents
Loop
Dim (b) As Byte
B=rc.inet1. GetChunk (0, icByteArray)
InetPOST=Utf8ToUnicode (b)
Cycle due to site data, so the POST, one page parameter, use found in the POST in the past whether page=1 or page=2 or other digital, return is the content of the page=1 (in fact, each page is different content), but after a few minutes to send page=2, return is the content of the page=2, if this time again send page=1 or page=3, return or the content of the page=2, is there a cache ace inet is it? What can I do to solve this problem?
CodePudding user response:
Option Explicit
Private Const INTERNET_OPEN_TYPE_PRECONFIG=0
Private Const INTERNET_OPEN_TYPE_DIRECT=1
Private Const INTERNET_OPEN_TYPE_PROXY=3
Private Const scUserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
"Private Const INTERNET_FLAG_RELOAD=& amp; H80000000
Private Declare Function InternetOpen Lib "wininet. DLL" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetOpenUrl Lib "wininet. DLL" Alias "InternetOpenUrlA" (ByVal hOpen As Long, ByVal sURL As String, ByVal sHeaders As String, ByVal lLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function InternetReadFileByte Lib "wininet. DLL" Alias "InternetReadFile" (ByVal hFile As Long, ByRef sBuffer As Byte, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As an Integer
Private Declare Function InternetCloseHandle Lib "wininet. DLL" (ByVal hInet As Long) As an Integer
Private Declare Function HttpQueryInfo Lib "wininet. DLL" Alias "HttpQueryInfoA" (ByVal hHttpRequest As Long, ByVal lInfoLevel As Long, ByVal sBuffer As Any, ByRef lBufferLength As Long, ByRef lIndex As Long) As an Integer
Const HTTP_QUERY_CONTENT_LENGTH=5
Const HTTP_QUERY_FLAG_NUMBER=& amp; H20000000
Private Declare Function InternetReadFile Lib "wininet. DLL" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As an Integer
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any Source, As Any, ByVal Length As Long)
Private Declare Function InternetConnect Lib "wininet. DLL" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal lpszServerName As String, ByVal nProxyWebPort As an Integer, ByVal lpszUsername As String, ByVal lpszPassword As String, ByVal dwService As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function HttpOpenRequest Lib "wininet. DLL" Alias "HttpOpenRequestA" (ByVal hInternetSession As Long, ByVal lpszVerb As String, ByVal lpszObjectName As String, ByVal lpszVersion As String, ByVal lpszReferer As String, ByVal lpszAcceptTypes As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function HttpSendRequest Lib "wininet. DLL" Alias "HttpSendRequestA" (ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal sOptional As String, ByVal lOptionalLength As Long) As Boolean
Private Declare Function HttpAddRequestHeaders Lib "wininet. DLL" Alias "HttpAddRequestHeadersA" (ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal lModifiers As Long) As an Integer
Private Function IsNullBytes (ByRef sBytes () As Byte) As Boolean
On the Error Resume Next
Dim N As Long
N=UBound (sBytes ())
If Err Then
IsNullBytes=True
End the If
End the Function
'Get
The Public Function WinInetGet (ByVal sURL As String, Optional ByVal lNewBufferSize As Long=2048) As Byte ()
Dim bBuffer () As Byte
Dim lBufferSize As Long
Dim retBytes () As Byte
Dim hOpen As Long
Dim hOpenUrl As Long
Dim hQuery As Long
Dim lFileSize As Long
Dim sQuery As String
Dim As Long I
Dim lBufferNumber As Long
Dim lRealFileLen As Long
Dim bDoLoop As Boolean
Dim lNumberOfBytesRead As Long
Dim BSize As Long
On Error GoTo FindErr
If lNewBufferSize & lt;> Then 2048
LBufferSize=lNewBufferSize
If lBufferSize & lt; 1024 Then lBufferSize=1024
The Else
LBufferSize=lNewBufferSize
End the If
ReDim bBuffer lBufferSize (1) the As Byte
HOpen=InternetOpen (scUserAgent INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
HOpenUrl=InternetOpenUrl (INTERNET_FLAG_RELOAD hOpen, sURL, vbNullString, 0, 0)
SQuery=$(1024, "") String
HQuery=HttpQueryInfo (hOpenUrl HTTP_QUERY_CONTENT_LENGTH, ByVal sQuery, Len (sQuery), 0)
If hQuery Then
LFileSize=CLng (Trim (sQuery))
The Else
LFileSize=1
End the If
If lFileSize & lt;> 1 Then
BDoLoop=True
LBufferNumber=Fix (lFileSize/lBufferSize)
If lFileSize Mod lBufferSize & lt;> 0 Then lBufferNumber=lBufferNumber + 1
LRealFileLen=0
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull