|
楼主 |
发表于 2011-1-29 21:18
|
显示全部楼层
webquery方式代码如下
没想到做着做着,网页查询的4种方式都做出来了
感叹个
厦门的,不需要POST数据的- Option Explicit
- Sub chaxun()
- Dim intnum As Integer
- Dim i As Integer
- Dim strdaima As String
- Dim strhaoma As String
- intnum = Application.WorksheetFunction.CountA([A:A])
- For i = 1 To intnum - 1
- Cells(2, 3).Value = "正在查询第" & i & "张"
- Application.ScreenUpdating = False
- strdaima = Cells(i + 1, 1).Value
- strhaoma = Cells(i + 1, 2).Value
- With ActiveSheet.QueryTables.Add(Connection:="URL;http://www.xm-n-tax.gov.cn/BrowseServlet?szsat.trancode=101007&szsat.errpage=%2Fjsp%2Finternet%2Findex%2FerrPage.jsp&szsat.normalpage=%2Fjsp%2Finternet%2Finforservice%2Fidentifyout.jsp&szsat.fpzw.fplx=&szsat.fpzw.fpdm=" & strdaima & "&szsat.fpzw.fphm=" & strhaoma, Destination:=Cells(1, 10))
- .Name = "第" & i & "张"
- .BackgroundQuery = False
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "13"
- .Refresh BackgroundQuery:=False
- End With
- Cells(i + 1, 4).Value = Cells(5, 12).Value
- Cells(i + 1, 5).Value = Cells(6, 12).Value
- Cells(i + 1, 6).Value = Cells(7, 12).Value
- Cells(i + 1, 7).Value = Cells(8, 12).Value
- Cells(i + 1, 8).Value = Cells(9, 12).Value
- Cells(i + 1, 9).Value = Cells(11, 11).Value
- Range("j1:o20").Clear
-
- Application.ScreenUpdating = True
- Next i
- Cells(2, 3).Value = "查询完毕!"
- MsgBox "OK"
- Cells(2, 3).Value = "查询状态提示栏"
- End Sub
复制代码 东莞的,需要POST数据的- Option Explicit
- Sub chaxun()
- Dim intnum As Integer
- Dim i As Integer
- Dim strdm As String
- Dim strhm As String
- Dim strdjh As String
- Dim strmc As String
- Dim strje As String
- Dim strrq As String
- Dim stra As String
- intnum = Application.WorksheetFunction.CountA([A:A])
- For i = 1 To intnum - 1
- Application.ScreenUpdating = False
- Cells(2, 7).Value = "正在查询第" & i & "张"
- strdm = Cells(i + 1, 1).Value
- strhm = Cells(i + 1, 2).Value
- strdjh = Cells(i + 1, 3).Value
- strmc = Cells(i + 1, 4).Value
- strje = Cells(i + 1, 5).Value
- strrq = Format(Cells(i + 1, 6).Value, "yyyy-mm-dd")
- stra = URLEncode(strmc)
- With ActiveSheet.QueryTables.Add(Connection:="URL;http://app.gd-n-tax.gov.cn/wssw/servlet/invoice_checking", Destination:=Range("J1"))
- .PostText = "fpdm=" & strdm & "&fphm=" & strhm & "&xhfswdjh=" & strdjh & "&xhfmc=" & stra & "&kpje=" & strje & "&kprq=" & strrq & "&INVOICE_CHECKING_CHECKCODE=2829&check_code=2829"
- .Name = "第" & i & "张"
- .BackgroundQuery = False
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "5"
- .Refresh BackgroundQuery:=False
- End With
- Cells(i + 1, 8).Value = Cells(3, 10).Value
- Range("j1:j10").Clear
- Application.ScreenUpdating = True
- Next i
- Cells(2, 7).Value = "查询完毕!"
- MsgBox "OK"
- Cells(2, 7).Value = "查询状态提示栏"
- End Sub
- Public Function URLEncode(strInput As String) As String
- '-------------------------------------------------------
- '示例: Debug.Print URLEncode("PowerBASIC中国")
- '-------------------------------------------------------
- Dim strOutput As String
- Dim intAscii As Integer
- Dim i As Integer
- Dim strTemp As String
- For i = 1 To Len(strInput)
- intAscii = Asc(Mid(strInput, i, 1))
- If ((intAscii < 58) And (intAscii > 47)) Or _
- ((intAscii < 91) And (intAscii > 64)) Or _
- ((intAscii < 123) And (intAscii > 96)) _
- Then
- strOutput = strOutput & Chr$(intAscii)
- Else
- strTemp = Trim$(Hex$(intAscii))
- strOutput = strOutput & "%" & Left(strTemp, 2) & "%" & Right(strTemp, 2)
- End If
- Next
- URLEncode = strOutput
- End Function
复制代码 |
|