|
仅仅针对你查不到的部分做了个工具,excel如附件
代码如下:- Sub chaxun()
- Dim xmlhttp As Object
- Dim Strtrasf As String, Ydh As String
- Dim Nm As Integer, i As Integer
- On Error Resume Next
- Nm = Application.WorksheetFunction.CountA([A:A])
- For i = 1 To Nm - 1
- Cells(2, 2).Value = "正在查询第" & i & "个"
- Ydh = Cells(i + 1, 1).Value
- Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
- xmlhttp.Open "POST", "http://222.73.105.202/kjcx/ajax.php", False
- xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- xmlhttp.Send "lb=tmfp&txm=" & Ydh
- Do Until xmlhttp.ReadyState = 4
- DoEvents
- Loop
- If xmlhttp.Status = 200 Then
- Strtrasf = Transfer(xmlhttp.responsetext)
- Cells(i + 1, 3).Value = Replace(Replace(Split(Filter(Split(Replace(Strtrasf, "'>", "'>["), ","), "[")(0), "[")(1), "<\/span>", ""), Chr(34), "")
- Cells(i + 1, 4).Value = Replace(Replace(Split(Filter(Split(Replace(Strtrasf, "'>", "'>["), ","), "[")(1), "[")(1), "<\/span>", ""), Chr(34) & "}", "")
- Else
- reportErr (xmlhttp.Status)
- End If
- Set xmlhttp = Nothing
- Cells(2, 2).Value = "查询完毕!"
- Cells(2, 2).Value = "查询状态提示栏"
- Next i
- MsgBox "OK"
- End Sub
- Sub reportErr(lStatus As Integer)
- Select Case lStatus
- Case 400
- MsgBox "Bad Request", vbCritical, "连接错误"
- Case 401
- MsgBox "Unauthorized", vbCritical, "连接错误"
- Case 402
- MsgBox "Payment Required", vbCritical, "连接错误"
- Case 403
- MsgBox "Forbidden", vbCritical, "连接错误"
- Case 404
- MsgBox "Not Found", vbCritical, "连接错误"
- Case 407
- MsgBox "Proxy Authentication Required", vbCritical, "连接错误"
- Case 408
- MsgBox "Request Timeout", vbCritical, "连接错误"
- Case 503
- MsgBox "Service Unavailable", vbCritical, "连接错误"
- Case Else
- MsgBox "Can not reach by other reason", vbCritical, "连接错误"
- End Select
- End Sub
- Function Transfer(str1 As String) As String
- Dim i%, y%, arr1(), arr2(), ireg As Object, imch As Object, mch As Object
- Set ireg = CreateObject("vbscript.regexp")
- ireg.Global = True
- ireg.Pattern = "\\u\w{4}"
- Set imch = ireg.Execute(str1)
- For Each mch In imch
- y = y + 1
- ReDim Preserve arr1(1 To y)
- ReDim Preserve arr2(1 To y)
- arr1(y) = ChrW(CLng(Replace(mch.Value, "\u", "&h")))
- arr2(y) = mch.Value
- Next
- For i = 1 To UBound(arr1)
- str1 = Replace(str1, arr2(i), arr1(i))
- Next
- Transfer = Trim(str1)
- Set ireg = Nothing
- End Function
复制代码 |
|