Public Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByRef lpMultiByteStr As Any, ByVal cchMultiByte As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long
Sub QueryStr() Dim strQuery As String Dim httpRequest As MSXML2.XMLHTTP30 Dim txtContent As String Dim strBuffer As String Dim lngBufferSize As Long Dim lngResult As Long Dim arrByte() As Byte Dim lSize As Long Dim l As Long strQuery = "cllb=6&zw=kc&file=kc&cpsb=&cpxh=&cpmc=&pici=&qymc=&cp_id=96904" Set httpRequest = New MSXML2.XMLHTTP30 httpRequest.Open "POST", "http://www.autoinfo.gov.cn/app/cpzz/qcxx.jsp?wenjian=kc", False httpRequest.setRequestHeader "Content-Type", "text/html" httpRequest.send strQuery If httpRequest.Status = 200 Then ReDim arrByte(UBound(httpRequest.responseBody)) As Byte For l = 0 To UBound(httpRequest.responseBody) arrByte(l) = httpRequest.responseBody(l) Next l lngBufferSize = (UBound(arrByte) + 1) * 2 strBuffer = String$(lngBufferSize, vbNullChar) lngResult = MultiByteToWideChar(936, 0, arrByte(0), lngBufferSize / 2, StrPtr(strBuffer), lngBufferSize) txtContent = Left(strBuffer, lngResult) 'MsgBox txtContent Cells(1, 1) = txtContent Else reportErr (httpRequest.Status) End If httpRequest.abort Set httpRequest = Nothing End Sub 程序倒是能顺利通过,但查询出来的没有什么实质内容 |