|
楼主 |
发表于 2011-2-13 14:11
|
显示全部楼层
河南的发票查询做好了
代码如下,excel见附件。- Option Explicit
- Sub chaxun()
- Dim xmlhttp As Object
- Dim a As Variant
- Dim fpdm As String
- Dim fphm As String
- Dim getpage As String
- Dim intnum As Integer
- Dim i As Integer
- Dim j As Integer
- Dim k As Integer
- Dim l As Integer
- intnum = Application.WorksheetFunction.CountA([A:A])
- For i = 1 To intnum - 1
- Cells(2, 3).Value = "正在查询第" & i & "张"
- fpdm = Cells(i + 1, 1).Value
- fphm = Cells(i + 1, 2).Value
- Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
- xmlhttp.Open "post", "http://www.12366.ha.cn//dwr/plaincall/callejb.getResultsetFpzw.dwr", False
- a = "callCount=1" & Chr(10)
- a = a & "httpSessionId=NWznZnhZ5GKxW62RpQhnj7hyn8VKJCGx1VmvCvyT75BQxYbG2yvD!-1138754356!1297494887928" & Chr(10)
- a = a & "scriptSessionId=82C832182E9958726D69C44E2D4128AB" & Chr(10)
- a = a & "page=/server/fpzwcx/index.jsp" & Chr(10)
- a = a & "c0-scriptName=callejb" & Chr(10)
- a = a & "c0-methodName=getResultsetFpzw" & Chr(10)
- a = a & "c0-id=7161_1297495974155" & Chr(10)
- a = a & "c0-param0=string:getFpzw" & Chr(10)
- a = a & "c0-e1=string:" & fpdm & Chr(10)
- a = a & "c0-e2=string:" & fphm & Chr(10)
- a = a & "c0-param1=Object:{FPDM:reference:c0-e1, FPHM:reference:c0-e2}" & Chr(10)
- xmlhttp.Send a
- Do Until xmlhttp.ReadyState = 4
- DoEvents
- Loop
- If xmlhttp.Status = 200 Then
- getpage = xmlhttp.responseText
-
- Dim nsrmc As String
- Dim nsrmcz As String
- nsrmc = Replace(Mid(getpage, InStr(getpage, "<NSRMC>") + 7, InStr(getpage, "</NSRMC>") - InStr(getpage, "<NSRMC>") - 7), "\u", "")
- For j = 1 To Len(nsrmc) Step 4
- nsrmcz = nsrmcz + ChrW(CInt("&H" & Mid(nsrmc, j, 4)))
- Next j
- Cells(i + 1, 4).Value = nsrmcz
- nsrmcz = Empty
- nsrmc = Empty
- Dim nsrsbh As String
- nsrsbh = Mid(getpage, InStr(getpage, "<NSRSBH>") + 8, InStr(getpage, "</NSRSBH>") - InStr(getpage, "<NSRSBH>") - 8)
- Cells(i + 1, 5).Value = nsrsbh
- nsrsbh = Empty
-
- Dim fpdmc As String
- fpdmc = Mid(getpage, InStr(getpage, "<FP_DM>") + 7, InStr(getpage, "</FP_DM>") - InStr(getpage, "<FP_DM>") - 7)
- Cells(i + 1, 6).Value = fpdmc
- fpdmc = Empty
- Dim fphmc As String
- fphmc = Mid(getpage, InStr(getpage, "<FPHM>") + 6, InStr(getpage, "</FPHM>") - InStr(getpage, "<FPHM>") - 6)
- Cells(i + 1, 7).Value = fphmc
- fphmc = Empty
- Dim fpmc As String
- Dim fpmcz As String
- fpmc = Replace(Mid(getpage, InStr(getpage, "<FPZL_MC>") + 9, InStr(getpage, "</FPZL_MC>") - InStr(getpage, "<FPZL_MC>") - 9), "\u", "")
- For k = 1 To Len(fpmc) Step 4
- fpmcz = fpmcz + ChrW(CInt("&H" & Mid(fpmc, k, 4)))
- Next k
- Cells(i + 1, 8).Value = fpmcz
- fpmcz = Empty
- fpmc = Empty
-
- Dim nsrzt As String
- Dim nsrztz As String
- nsrzt = Replace(Mid(getpage, InStr(getpage, "<NSRZT_MC>") + 10, InStr(getpage, "</NSRZT_MC>") - InStr(getpage, "<NSRZT_MC>") - 10), "\u", "")
- For l = 1 To Len(nsrzt) Step 4
- nsrztz = nsrztz + ChrW(CInt("&H" & Mid(nsrzt, l, 4)))
- Next l
- Cells(i + 1, 9).Value = nsrztz
- nsrztz = Empty
- nsrzt = Empty
-
- Set xmlhttp = Nothing
- getpage = Empty
- Else
- MsgBox xmlhttp.statusText
- End If
-
- Next i
-
- Cells(2, 3).Value = "查询完毕!"
- MsgBox "OK"
- Cells(2, 3).Value = "查询状态提示栏"
-
- 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
复制代码 |
|